Jump to content

Pause and Play example


Jblz619
 Share

Recommended Posts

      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 by Jblz619
Link to comment
Share on other sites

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

When the words fail... music speaks.

Link to comment
Share on other sites

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 by Jblz619
Link to comment
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
 Share

×
×
  • Create New...