Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ButtonConstants.au3>
- #include <GUIConstantsEx.au3>
- #include <WindowsConstants.au3>
- #include <MsgBoxConstants.au3>
- Opt("GUIOnEventMode", 1)
- Global $g_bPaused = -1
- Global $Pausecode=-1
- #Region ### START Koda GUI section ### Form=
- $Form1 = GUICreate("Form1", 336, 72, 192, 124)
- $btn_begin = GUICtrlCreateButton("Start Click", 16, 16, 137, 33)
- GUICtrlSetOnEvent($btn_begin, "begin")
- $btn_pause = GUICtrlCreateButton("Pause / Resume", 184, 16, 137, 33)
- GUICtrlSetOnEvent($btn_pause, "pause")
- GUISetState(@SW_SHOW)
- #EndRegion ### END Koda GUI section ###
- GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
- ;Example
- Func begin()
- ; loop is example, i need : when i click button btn_pause then func begin() will pause
- For $i = 1 To 10
- While 1
- MsgBox($MB_SYSTEMMODAL, "Title", "This message box will timeout after 10 seconds or select the OK button.", 10)
- Sleep(500)
- If $g_bPaused <> 0 Then
- ; The flag was set
- Switch $g_bPaused
- Case 1
- ConsoleWrite("Script is Paused" & @CRLF)
- EndSwitch
- While $Pausecode=1
- ConsoleWrite("Script is Paused, Click again to Resume" & @CRLF)
- Sleep(200)
- WEnd
- EndIf
- Sleep(100)
- WEnd
- ConsoleWrite(">Func begin Ended" & @CRLF)
- Next
- Sleep(50)
- EndFunc ;==>begin
- Func pause()
- ;~ ConsoleWrite("Script is Paused" & @CRLF)
- EndFunc
- Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
- ; The Func 2 button was pressed so set the flag
- If BitAND($wParam, 0x0000FFFF) = $btn_pause Then
- $g_bPaused = -$g_bPaused
- $Pausecode=-$Pausecode
- EndIf
- EndFunc ;==>_WM_COMMAND
- While 1
- Sleep(10)
- WEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement