Jump to content
Sign in to follow this  
stuckors

Exiting Loop

Recommended Posts

I have made a loop to press 7 and click until i tell it to stop. Problem is I can't figure out how to tell it to exit loop. I use PgDn key to start it and want PgUp key to end it. Help please. :lmao:

Share this post


Link to post
Share on other sites

I have made a loop to press 7 and click until i tell it to stop. Problem is I can't figure out how to tell it to exit loop. I use PgDn key to start it and want PgUp key to end it. Help please. :lmao:

Direct from the hotkeyset helpfile with minor edits

http://www.autoitscript.com/autoit3/docs/f...s/HotKeySet.htm

; Press pgup to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{PgUp}", "Terminate")
HotKeySet("{PgDn}", "Start")  ;Shift-Alt-d

;;;; Body of program would go here ;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func Start()
While 1
;do whatever
Wend
EndFunc
Edited by Paulie

Share this post


Link to post
Share on other sites

I have everything else good except this part. (I want it to exit the loop when i press PgUp)

Case $msg = $start
      Global $Paused
HotKeySet("{Pgdn}","start")  
GUISetState(@SW_Hide)
While 1
    Sleep(100)
WEnd
Func start() 
[b]While 1
    Send ("7")
    MouseClick ("left")
WEnd [/b] 
EndFunc 
EndSelect

I have a gui with some buttons so i can put multiple options in 1 script.

Direct from the hotkeyset helpfile with minor edits

http://www.autoitscript.com/autoit3/docs/f...s/HotKeySet.htm

Looked at that, didn't help. Edited by stuckors

Share this post


Link to post
Share on other sites

I have everything else good except this part. (I want it to exit the loop when i press PgUp)

Case $msg = $start
      Global $Paused
HotKeySet("{Pgdn}","start")  
GUISetState(@SW_Hide)
While 1
    Sleep(100)
WEnd
Func start() 
[b]While 1
    Send ("7")
    MouseClick ("left")
WEnd [/b] 
EndFunc 
EndSelect

I have a gui with some buttons so i can put multiple options in 1 script.

Use the 'terminate' function that was in my above script

Share this post


Link to post
Share on other sites

Problem is i don't want the script to close, just to exit loop with PgUp.

then replace the "{pause}" thing and then you can toggle it on and off with one key

like this

Global $Paused = true
HotKeySet("{PgUp}", "TogglePause")
HotKeySet("{ESC}", "Terminate")


;;;; Body of program would go here ;;;;
While 1
    ;Do Whatever
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc
Edited by Paulie

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  

×
×
  • Create New...