Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. #include <ButtonConstants.au3>
  2. #include <GUIConstantsEx.au3>
  3. #include <WindowsConstants.au3>
  4. #include <MsgBoxConstants.au3>
  5. Opt("GUIOnEventMode", 1)
  6.  
  7. Global $g_bPaused = -1
  8. Global $Pausecode=-1
  9.  
  10.  
  11. #Region ### START Koda GUI section ### Form=
  12. $Form1 = GUICreate("Form1", 336, 72, 192, 124)
  13. $btn_begin = GUICtrlCreateButton("Start Click", 16, 16, 137, 33)
  14. GUICtrlSetOnEvent($btn_begin, "begin")
  15. $btn_pause = GUICtrlCreateButton("Pause / Resume", 184, 16, 137, 33)
  16. GUICtrlSetOnEvent($btn_pause, "pause")
  17. GUISetState(@SW_SHOW)
  18. #EndRegion ### END Koda GUI section ###
  19. GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
  20.  
  21.  
  22. ;Example
  23. Func begin()
  24. ; loop is example, i need : when i click button btn_pause then func begin() will pause
  25. For $i = 1 To 10
  26. While 1
  27. MsgBox($MB_SYSTEMMODAL, "Title", "This message box will timeout after 10 seconds or select the OK button.", 10)
  28. Sleep(500)
  29.  
  30.  
  31. If $g_bPaused <> 0 Then
  32. ; The flag was set
  33. Switch $g_bPaused
  34. Case 1
  35. ConsoleWrite("Script is Paused" & @CRLF)
  36. EndSwitch
  37. While $Pausecode=1
  38. ConsoleWrite("Script is Paused, Click again to Resume" & @CRLF)
  39. Sleep(200)
  40. WEnd
  41.  
  42. EndIf
  43. Sleep(100)
  44. WEnd
  45. ConsoleWrite(">Func begin Ended" & @CRLF)
  46.  
  47.  
  48. Next
  49. Sleep(50)
  50. EndFunc ;==>begin
  51.  
  52.  
  53.  
  54. Func pause()
  55. ;~ ConsoleWrite("Script is Paused" & @CRLF)
  56. EndFunc
  57.  
  58.  
  59.  
  60. Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
  61. ; The Func 2 button was pressed so set the flag
  62. If BitAND($wParam, 0x0000FFFF) = $btn_pause Then
  63. $g_bPaused = -$g_bPaused
  64. $Pausecode=-$Pausecode
  65. EndIf
  66.  
  67. EndFunc ;==>_WM_COMMAND
  68.  
  69.  
  70.  
  71. While 1
  72. Sleep(10)
  73. WEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement