Jump to content
jo0oker

how to fix my problem with (for loop)

Recommended Posts

jo0oker

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 

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("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

 

2017-10-28_112651.png

Share this post


Link to post
Share on other sites
jo0oker

its called by HotKeySet

 

Global $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

 

Share this post


Link to post
Share on other sites
Jos

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
jo0oker

but now the array calls the functions first before  i call the (start) {Hotkey}. without (for loop) ...its confusing

Share this post


Link to post
Share on other sites
Jos

no idea what you are trying to tell us here, but you will have to define the array before you can use it.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
jo0oker

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

Share this post


Link to post
Share on other sites
Jos

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
 


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
gruntydatsun

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

Share this post


Link to post
Share on other sites
Sleepyguy

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. 

Share this post


Link to post
Share on other sites
Jos
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

 


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
JLogan3o13

@Sleepyguy the OP declares $i as the counter in his For loop in the Start() function, all that is needed


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.