jo0oker Posted October 28, 2017 Share Posted October 28, 2017 Hello, i have many function in my script call (User) and i tried many times to make them working with (for) loop , but every time get error (Variable used without being declared) , now i need any solutions to complete the script please. there is image for script and error my code expandcollapse popupGlobal $array[6] $array[0] = USER1() $array[1] = USER2() $array[2] = USER3() $array[3] = USER4() $array[4] = USER5() $array[5] = USER6() Func Start() ToolTip("start",0,0) WinActivate("My_window") For $i = 0 To 5 Step +1 Next EndFunc Func USER1() ToolTip("USER1",0,0) Local $pos = MouseGetPos() MouseClick("left",1443, 88,1,10) MouseMove($pos [0],$pos [1],10) Sleep(2000) MouseClick("left",1440, 902,1,10) MouseMove($pos [0],$pos [1],10) Sleep(2000) MouseClick("left",1866, 199,1,10) MouseMove($pos [0],$pos [1],10) Sleep(2000) EndFunc Func USER2() ToolTip("USER1",0,0) Local $pos = MouseGetPos() MouseClick("left",1443, 88,1,10) MouseMove($pos [0],$pos [1],10) Sleep(2000) MouseClick("left",1440, 902,1,10) MouseMove($pos [0],$pos [1],10) Sleep(2000) MouseClick("left",1866, 199,1,10) MouseMove($pos [0],$pos [1],10) Sleep(2000) EndFunc Link to comment Share on other sites More sharing options...
Developers Jos Posted October 28, 2017 Developers Share Posted October 28, 2017 Just post the whole script so we can see how the Func Start is called. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
jo0oker Posted October 28, 2017 Author Share Posted October 28, 2017 its called by HotKeySet expandcollapse popupGlobal $Paused HotKeySet("{F1}", "Start") HotKeySet("{F2}", "Pause") HotKeySet("{F3}", "Close") HotKeySet("{F4}", "map") _Startup() Func _Startup() While 1 ToolTip("Startup",0,40) Sleep(100) WEnd EndFunc Func Close() Exit EndFunc Func Pause() ToolTip("Pause",0,0) $Paused = NOT $Paused While $Paused sleep(100) WEnd EndFunc Func Moswll() Send("{CTRLDOWN}") MouseWheel("down",6) Send("{CTRLUP}") Sleep(2000) EndFunc Global $array[6] $array[0] = USER1() $array[1] = USER2() $array[2] = USER3() $array[3] = USER4() $array[4] = USER5() $array[5] = USER6() Func Start() ToolTip("start",0,0) WinActivate("jo0oker") For $i = 0 To 5 Step +1 Next EndFunc Link to comment Share on other sites More sharing options...
Developers Jos Posted October 28, 2017 Developers Share Posted October 28, 2017 That means that it will never reach the part where the Array is defined so change that to: Global $Paused Global $array[6] $array[0] = USER1() $array[1] = USER2() $array[2] = USER3() $array[3] = USER4() $array[4] = USER5() $array[5] = USER6() HotKeySet("{F1}", "Start") HotKeySet("{F2}", "Pause") HotKeySet("{F3}", "Close") HotKeySet("{F4}", "map") _Startup() Func _Startup() While 1 ToolTip("Startup",0,40) Sleep(100) WEnd EndFunc Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
jo0oker Posted October 28, 2017 Author Share Posted October 28, 2017 but now the array calls the functions first before i call the (start) {Hotkey}. without (for loop) ...its confusing Link to comment Share on other sites More sharing options...
Developers Jos Posted October 28, 2017 Developers Share Posted October 28, 2017 no idea what you are trying to tell us here, but you will have to define the array before you can use it. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
jo0oker Posted October 28, 2017 Author Share Posted October 28, 2017 yes the array is defined but the problem now when i run script code, the verb $array call the function of users one by on directly ,and all hotkeys stopped thx Jos Younes Link to comment Share on other sites More sharing options...
Developers Jos Posted October 28, 2017 Developers Share Posted October 28, 2017 Again, I have no idea what you are trying to do with this script so only helped with why you had the error. You will have to be much more explicit on this issue you have now before anyone can assist you further. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
gruntydatsun Posted October 30, 2017 Share Posted October 30, 2017 What is the purpose of the array? I guessing the array is to hold the names of the functions so you can run them elsewhere using Execute($array[4]) or something like that? As it is now, when you instantiate that array you are running the functions and assigning whatever they return to the array elements, which is nothing in this case. You might want to put them in there as strings... like $array[2]="functionname" hth Link to comment Share on other sites More sharing options...
Sleepyguy Posted October 30, 2017 Share Posted October 30, 2017 I am likely way over my head in this but declaring the array you need to add Local $i = 0 Do you not? I do not see it in any of the posted code. Link to comment Share on other sites More sharing options...
Developers Jos Posted October 30, 2017 Developers Share Posted October 30, 2017 16 minutes ago, Sleepyguy said: I am likely way over my head in this but declaring the array you need to addLocal $i = 0 Why do you feel this is needed? The $i in the For...Next in implicitly declaredas stated in the Helpfile: Quote Remarks The variable will be created automatically with Local scope, even when MustDeclareVars is on. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 30, 2017 Moderators Share Posted October 30, 2017 @Sleepyguy the OP declares $i as the counter in his For loop in the Start() function, all that is needed "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! 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