Sign in to follow this  
Followers 0
Rydextillxixdiex

Hotkeys to Stop Loop

7 posts in this topic

I need help with hotkeys, and setting varriables to different functions so that a hot key will STOP a function when pressed. The hot key currently STARTS the function, but the STOP function doesn't infact stop the loop. Can anyone help?

HotKeySet("{F9}", "Start")
HotKeySet("{F10}", "Stop")

While 1
    Sleep(1000)
WEnd

Func start()
    Global $show = 0
While 1
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send(4)
        Sleep(30000)
        Send(4)
        Sleep(30000)
        Send(4)
        sleep(20)
        Send("i")
        If $show = 1 Then ExitLoop
WEnd
EndFunc   ;==>start


Func stop()
    Global $show = 1
EndFunc   ;==>stop

Thanks. Maybe "Global $show = 1" in the stop function needs to be inside a "while" - "wend"? im not sure. Thanks for any help.


...will never learn all there is to know about autoit, no worries...i came to the forums :)

Share this post


Link to post
Share on other sites



Don`t declare the Global variable in function, it`s wrong.

HotKeySet("{F9}", "Start")
HotKeySet("{F10}", "Stop")

Global $show = 0

While 1
    Sleep(100)
WEnd

Func start()
    $show = 0
    While 1
        If $show = 1 Then ExitLoop
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send(4)
        Sleep(30000)
        Send(4)
        Sleep(30000)
        Send(4)
        sleep(20)
        Send("i")
    WEnd
EndFunc   ;==>start


Func stop()
    Global $show = 1
EndFunc   ;==>stop

Share this post


Link to post
Share on other sites

None of this worked... :)


...will never learn all there is to know about autoit, no worries...i came to the forums :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

None of this worked... :)

HotKeySet("{F9}", "Start") 
HotkeySet("{F10}", "Stop") 
Global $show = 0 
While 1 
If $show = 1 Then 
Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send("{LSHIFT down}")
        sleep(100)
        MouseClick("Right", 653, 358, 1, 0)
        sleep(100)
        Send("{LSHIFT up}")
        Sleep(5000)
        Send(4)
        Sleep(30000)
        Send(4)
        Sleep(30000)
        Send(4)
        sleep(20)
        Send("i")




If $show = 1 Then 
Sleep(1000) 
Else 
ExitLoop 
EndIf 
EndIF
Wend


Func Start() 
   $show = 1 
EndFunc 

Func Stop() 
   $show = 0 
EndFunc

try that

Edited by will88

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Rydextillxixdiex

None of this worked...

You tried to use my example? Edited by rasim

Share this post


Link to post
Share on other sites

if you want to kill the process entirelly. use this.

Global $Paused

HotKeySet("{ESC}", "Terminate")

Func Terminate()

Exit 0

EndFunc

Make sure it is at the Very start of your program`s scriptlines.

With that line there, Pressing ESC will terminate the program

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
Sign in to follow this  
Followers 0