Jiggaboo Posted January 27, 2007 Posted January 27, 2007 Hey guys, I was wondering if anyone could help me out here. Basically, I have a GUI button labeled "Pause" and when its clicked, it runs the TogglePause() function: Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc And, when I click the Pause button, it pauses it just fine, but I cannot get it out of the Paused state. I get no response from any other events. ALSO! I have Pause set as a hotkey (to run the TogglePause function) - Would this have anything to do with it? (I can Pause/UnPause just fine using the hotkey) Any help would be greatly appreciated! -Jiggaboo
BALA Posted January 27, 2007 Posted January 27, 2007 (edited) I think that when you click the "pause" key, your script stays in the pause state forever because of the loop you have. Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) $key = ;set what key to check for If _IsPressed($key) Then ExitLoop ; Exit out of pause Wend WEnd ToolTip("") EndFunc Edited January 27, 2007 by BALA [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Jiggaboo Posted January 27, 2007 Author Posted January 27, 2007 Thanks for the reply, but I am still having trouble here ... expandcollapse popupWhile 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 ;Start ;(...) Case $msg = $Button_2 ;Pause $Paused = NOT $Paused While $Paused $msg = GUIGetMsg() sleep(100) ToolTip('Script is "Paused"',0,0) WEnd if $msg = $Button_2 then ;$Paused = NOT $Paused ToolTip("") EndIf Case $msg = $Button_3 ;Exit ;(...) Exit Case Else ;;; EndSelect WEnd Exit ;Basic Functions Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) $key = $Button_2;set what key to check for ;If isIsPressed($key) Then ; ExitLoop ; Exit out of pause ;EndIf WEnd ToolTip("") EndFunc Sorry for the obvious questions, dont work with Au3 very much ><
BALA Posted January 27, 2007 Posted January 27, 2007 (edited) By $key I meant the hex for the key. An easier way in my opinion would be to set a HotKey. HotKeySet("{F1}", "UnPause");sets F1 key that will unpause if pressed Func Unpause() ;leave blank to just unpause EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Edited January 27, 2007 by BALA [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Jiggaboo Posted January 27, 2007 Author Posted January 27, 2007 Yeah, just using a hotkey to Pause/UnPause would definitely be easier, but I would prefer to just have a button on the GUI, so it kinda feels like the Center of the program. You start/pause/exit/etc. all in the GUI. I guess I am making this more of a problem than it should be. What I want, is to have a Pause button, and when you click it - the script pauses. When you click it again, it unpauses. I guess, I honestly dont know how to do this T_T
BALA Posted January 27, 2007 Posted January 27, 2007 (edited) Yeah, just using a hotkey to Pause/UnPause would definitely be easier, but I would prefer to just have a button on the GUI, so it kinda feels like the Center of the program. You start/pause/exit/etc. all in the GUI. I guess I am making this more of a problem than it should be. What I want, is to have a Pause button, and when you click it - the script pauses. When you click it again, it unpauses. I guess, I honestly dont know how to do this T_T Oh in that case, you would do something like this: $stop = GUICtrlCreateButton("Stop (F4)", 40, 120, 120) ; unpause button GUICtrlSetOnEvent($stop, "Stop") ; tells to go to function if pressed Func Stop() ;leave blank or tell it to do something else EndFunc Edited January 27, 2007 by BALA [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
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