Jump to content

Recommended Posts

Posted

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

Posted (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 by Subz
Forgot to add Pause
Posted (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 by KickStarter15

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...