Jblz619 Posted October 7, 2023 Posted October 7, 2023 (edited) There seems to be many bad forum posts and confusion on the simple action of toggling pause and play. Here is two examples of playing and pausing shortcuts. I'm sure there may be multiple ways to do this. Or there maybe more efficient ways but this was the simple way I do it Example one: Two shortcuts that toggle Pause and Play HotKeySet("{insert}","_Pause");press insert to make $pause variable = 1 and resume actions HotKeySet("{esc}","_Play");press esc to make $pause variable = 0 $pause=1; sets varriable to 1 starting actiions in loop While 1; Loop every 500 mill seconds and check varriables Sleep(500); check variable every 500 seconds if $pause=1 Then; if $pause variable = 1 then do actions ;Do actions EndIf WEnd func _Play() $pause=0 EndFunc func _Pause() $pause=1 EndFunc Example Two: One shortcut that toggle Pause and Play HotKeySet("{insert}","_Pause");press insert to make $pause press insert again to resume $pause=1; sets varriable to 1 starting actiions in loop While 1; Loop every 500 mill seconds and check varriables Sleep(500); check variable every 500 seconds if $pause=1 Then; if $pause variable = 1 then do actions ;Do actions while $pause = 1 EndIf WEnd func _Pause() if $pause=0 then $pause=1 else $pause=0 endif EndFunc Edited October 7, 2023 by Jblz619
Andreik Posted October 7, 2023 Posted October 7, 2023 Not sure about what confusion are you talking but this is a trivial thing. This is how I implement pause in my apps: HotKeySet('{PAUSE}', 'Pause') While True ConsoleWrite('The script is running.' & @CRLF) Sleep(10) WEnd Func Pause() Local Static $Paused = False $Paused = Not $Paused If $Paused Then ConsoleWrite('The script is paused.' & @CRLF) Do Sleep(10) Until Not $Paused EndFunc taurus905 1
Jblz619 Posted October 7, 2023 Author Posted October 7, 2023 (edited) Cool i'm sure there is multiple ways ty. That's 3 good examples. Now the confusion i mention is if you google search you will find a bunch of miss information and people failing at the most simple of pause and play. Edited October 7, 2023 by Jblz619
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