jeroen96 Posted September 17, 2015 Share Posted September 17, 2015 Hello, I want to know if there is a shorter way to write this: expandcollapse popupFunc mouse_co () $a += 1 If $a = 1 Then Global $m1 = MouseGetPos () ElseIf $a = 2 Then Global $m2 = MouseGetPos () ElseIf $a = 3 Then Global $m3 = MouseGetPos () ElseIf $a = 4 Then Global $m4 = MouseGetPos () ElseIf $a = 5 Then Global $m5 = MouseGetPos () ElseIf $a = 6 Then Global $m6 = MouseGetPos () ElseIf $a = 7 Then Global $m7 = MouseGetPos () ElseIf $a = 8 Then Global $m8 = MouseGetPos () ElseIf $a = 9 Then Global $m9 = MouseGetPos () ElseIf $a = 10 Then Global $m10 = MouseGetPos () ElseIf $a = 11 Then Global $m11 = MouseGetPos () ElseIf $a = 12 Then Global $m12 = MouseGetPos () EndIf EndFunc Func mouse_co2 () If $a >= 1 Then Send ("(" & $m1[0] & "," & $m1[1] & ")" & @CRLF) If $a >= 2 Then Send ("(" & $m2[0] & "," & $m2[1] & ")" & @CRLF) If $a >= 3 Then Send ("(" & $m3[0] & "," & $m3[1] & ")" & @CRLF) If $a >= 4 Then Send ("(" & $m4[0] & "," & $m4[1] & ")" & @CRLF) If $a >= 5 Then Send ("(" & $m5[0] & "," & $m5[1] & ")" & @CRLF) If $a >= 6 Then Send ("(" & $m6[0] & "," & $m6[1] & ")" & @CRLF) If $a >= 7 Then Send ("(" & $m7[0] & "," & $m7[1] & ")" & @CRLF) If $a >= 8 Then Send ("(" & $m8[0] & "," & $m8[1] & ")" & @CRLF) If $a >= 9 Then Send ("(" & $m9[0] & "," & $m9[1] & ")" & @CRLF) If $a >= 10 Then Send ("(" & $m10[0] & "," & $m10[1] & ")" & @CRLF) If $a >= 11 Then Send ("(" & $m11[0] & "," & $m11[1] & ")" & @CRLF) If $a >= 12 Then Send ("(" & $m12[0] & "," & $m12[1] & ")" & @CRLF) EndIf EndIf EndIf EndIf EndIf EndIf EndIf EndIf EndIf EndIf EndIf EndIf EndFunc I want to use this to a max $a but in this way it costs a lot of timethanks Link to comment Share on other sites More sharing options...
water Posted September 17, 2015 Share Posted September 17, 2015 Use Arrays and Switch instead of multiple If/Then/Else. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
czardas Posted September 17, 2015 Share Posted September 17, 2015 Don't declare Global variables inside a function - that's not the best way to write code. I don't understand the purpose of this. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
JohnOne Posted September 17, 2015 Share Posted September 17, 2015 Without a real example how these functions are used, it will be difficult to offer any further advice without wasting time. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jeroen96 Posted September 17, 2015 Author Share Posted September 17, 2015 Thank you for your responses, i foud a way to do this Func mouse_co () $m = MouseGetPos () $coord = $coord & "The coordinations are: (" & $m[0] & "," & $m[1] & ")" & @CRLF MsgBox (0,"",$coord) EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now