Justforfun Posted August 23, 2010 Share Posted August 23, 2010 Hello, I am wondering if there is a way to pause a script but have it finish the current loop then pause instead of just pausing right away. I am using the Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip("Paused", 1, 1) WEnd ToolTip("") EndFunc function to pause right now. The problem I am having is I have a script that uses alot of pixelsearch functions and sometimes when I press pause I get the $array has no variable error because the script is being paused right before the pixel search is able to check @error and return the array. Thanks in Advance for help. Link to comment Share on other sites More sharing options...
JohnOne Posted August 23, 2010 Share Posted August 23, 2010 One way would be to have your hotkeyset function to just change the boolean state of the $paused variable. And have a safe point in your loop which checks it and pauses if True. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
ShawnW Posted August 23, 2010 Share Posted August 23, 2010 correct something like: ; Loop While True Sleep(1) ; Sleep 1 is all you need to slow the cpu unless you only wanted 10/sec If Not $Paused Then ToolTip("") ; .... code here Else ToolTip("Paused", 1, 1) EndIf WEnd Func TogglePause() $Paused = Not $Paused EndFunc Link to comment Share on other sites More sharing options...
Justforfun Posted August 24, 2010 Author Share Posted August 24, 2010 Thanks Guys took the advice and came up with Global $Paused HotKeySet("{F7}", "TogglePause") Func TogglePause() If @error < 2 Then $Paused = Not $Paused While $Paused Sleep(1) ToolTip('', 691, 325) WEnd ToolTip("") EndIf EndFunc ;==>TogglePause Not a big change but it pauses it after the @error array is returned no more no array virable error Thanks Again Link to comment Share on other sites More sharing options...
AlmarM Posted August 24, 2010 Share Posted August 24, 2010 (edited) Thanks Guys took the advice and came up with Global $Paused HotKeySet("{F7}", "TogglePause") Func TogglePause() If @error < 2 Then $Paused = Not $Paused While $Paused Sleep(1) ToolTip('', 691, 325) WEnd ToolTip("") EndIf EndFunc ;==>TogglePause Not a big change but it pauses it after the @error array is returned no more no array virable error Thanks Again This should work: HotKeySet("{PAUSE}", "_Pause") HotKeySet("{ESC}", "_Exit") Global $Pause = False While Sleep(25) WEnd Func _Pause() $Pause = Not $Pause While $Pause ToolTip("Paused", 0, 0) Sleep(25) WEnd ToolTip("") EndFunc Func _Exit() Exit EndFunc Edited August 24, 2010 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now