Jump to content

Recommended Posts

Posted

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

Posted

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

 

  • Developers
Posted

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.
  :)

Posted

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

  • Developers
Posted

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.
  :)

Posted

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

  • Developers
Posted
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.
  :)

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
×
×
  • Create New...