Jump to content
Sign in to follow this  
Shicken

Help with Pausing

Recommended Posts

Shicken

I'm still learning as much as I can with AutoIt, and I need a command that can pause it until I press the button again...

I know how to completley stop the script, then in order to run it I have to run the script manually.

So if I could get a bit of code with it setting the hotkey along with the pause command, that'd be great.

Thanks,

Shicken


Share this post


Link to post
Share on other sites
SlimShady

AutoItSetOption("TrayIconDebug", 1)

;Initialize variable
Global $Paused

;Set start state as "not paused"
$Paused = 0

;Show user that the script is NOT paused
ToolTip("Script is NOT paused")

;Press "Pause" to toggle the pause state
HotKeySet("{PAUSE}", "TogglePause")

;Body of your script
;You can remove this loop if you want
While 1
   Sleep(500)
WEnd

;Functions you need

Func TogglePause()
  ;Swap current state
   $Paused = NOT $Paused
   
   If $Paused Then
     ;Show user that the script is paused
      ToolTip("Script is paused")
      
     ;Pause the script
      Pause()
   Else
     ;Show user that the script is NOT paused
      ToolTip("Script is NOT paused")
   EndIf
EndFunc

Func Pause()
  ;Pause
   While $Paused
      Sleep(100)
   WEnd
EndFunc

Share this post


Link to post
Share on other sites
Henrik

$dummy MsgBox(64, "Script waiting", "Hit OK to unpause the script.")


Ignorance is strength.

Share this post


Link to post
Share on other sites
Shicken

Thanks for the help guys :)


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  

×