Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.19 KB | None | 0 0
  1. #include <GUIConstantsEx.au3>
  2.  
  3. Global $was_stop = 0
  4.  
  5. GUICreate("My GUI Button")
  6. $Button_1 = GUICtrlCreateButton("Button_1", 10, 30, 100)
  7. $Button_2 = GUICtrlCreateButton("Button_2", 120, -1)
  8. GUISetState()
  9.  
  10. While 1
  11.     $msg = GUIGetMsg()
  12.     Select
  13.         Case $msg = $GUI_EVENT_CLOSE
  14.             ExitLoop
  15.         Case $msg = $Button_1
  16.             _Function1()
  17.     EndSelect
  18. WEnd
  19.  
  20. Func _Function1()
  21.     $was_stop = 0
  22.     for $i=1 to 100
  23.     While 1
  24.         If IsStop() Then Return
  25.         ConsoleWrite("running" & @CRLF)
  26.         ; some code 1
  27.         ; ...
  28.         ;If IsStop() Then Return
  29.         ; some code 2
  30.         ConsoleWrite("runningaaaa" & @CRLF)
  31.         Sleep(100)
  32.         ExitLoop
  33.      WEnd
  34.       While 1
  35.          If IsStop() Then Return
  36.         ConsoleWrite("runningccccc" & @CRLF)
  37.         ; some code 1
  38.         ; ...
  39.         ;If IsStop() Then Return
  40.         ; some code 2
  41.         ConsoleWrite("runningaaaabbbbb" & @CRLF)
  42.         ConsoleWrite("runningaaaabbbbbcccc" & @CRLF)
  43.         Sleep(100)
  44.         ExitLoop
  45.      WEnd
  46.      Next
  47. EndFunc
  48.  
  49. Func IsStop()
  50.     If $was_stop Then Return 1
  51.     If GUIGetMsg() = $Button_2 Then
  52.         $was_stop = 1
  53.         Return 1
  54.     EndIf
  55.     Return 0
  56. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement