prasad123 Posted February 9, 2018 Share Posted February 9, 2018 Hi All I have this code with which I am able to pause and resume my program. The functions work perfectly. However I wanted to display 2 messages: When I press pause first time, it should display "Program paused" When I press pause second time, it should display "Program resumed" Without being able to display these messages, the pausing and resuming is happening properly. But I am having trouble with the messages. HotKeySet("{PAUSE}", "TogglePause") Func TogglePause() $Paused = Not $Paused While $Paused Sleep(10) WEnd EndFunc Can someone please help me with the messages ?? Thanks in advance Link to comment Share on other sites More sharing options...
Subz Posted February 9, 2018 Share Posted February 9, 2018 (edited) Maybe something like: $Paused = False HotKeySet("{PAUSE}", "TogglePause") While 1 Sleep(10) Wend Func TogglePause() If $Paused Then $Paused = False MsgBox(32, "Result", "Program Resumed") ElseIf $Paused = False Then $Paused = True MsgBox(32, "Result", "Program Paused") EndIf While $Paused Sleep(10) WEnd EndFunc Edited February 9, 2018 by Subz Forgot to add Pause prasad123 1 Link to comment Share on other sites More sharing options...
KickStarter15 Posted February 9, 2018 Share Posted February 9, 2018 (edited) Or #include <MsgBoxConstants.au3> ; Press Esc to terminate script, Pause/Break to "pause" Global $Paused = False HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") While 1 Sleep(100) WEnd Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) $msg = MsgBox($MB_SYSTEMMODAL, "", "Script Paused!") If $msg = 1 Then MsgBox($MB_SYSTEMMODAL, "", "Script Resumed!") Exit EndIf WEnd EndFunc ;==>TogglePause Func Terminate() Exit EndFunc ;==>Terminate Edited February 9, 2018 by KickStarter15 prasad123 1 Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. 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