Guest User

Untitled

a guest
Apr 7th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.24 KB | None | 0 0
  1. #cs ----------------------------------------------------------------------------
  2.  
  3.  AutoIt Version: 3.3.6.1
  4.  Author:         FreeCoder
  5.  
  6.  Script Function:
  7.     Example AutoIt script.
  8.  
  9. #ce ----------------------------------------------------------------------------
  10.  
  11. #include <GUIConstantsEx.au3>
  12.  
  13. Global $timer = 0
  14.  
  15. Global $hGui      = GUICreate("Test", 250, 40)
  16. Global $checkBox1 = GUICtrlCreateCheckbox("Timer:", 20, 10)
  17. Global $textBox1  = GUICtrlCreateInput("5", 75, 10)
  18. Global $label1    = GUICtrlCreateLabel("Sekunden", 135, 13)
  19. Global $button1   = GUICtrlCreateButton("Start", 190, 8, 50)
  20.  
  21. GUISetState(@SW_SHOW, $hGui)
  22.  
  23. While True
  24.     ; Checkout GUI events...
  25.     $msg = GUIGetMsg()
  26.     Switch $msg
  27.         Case -3
  28.             Exit
  29.         Case $button1
  30.             $timer = TimerInit()
  31.     EndSwitch
  32.  
  33.     ; Disable/Enable Textbox
  34.     Local $state = GUICtrlRead($checkBox1)
  35.     If $state = 1 Then
  36.         GUICtrlSetState($textBox1, $GUI_ENABLE)
  37.     ElseIf $state = 4 Then
  38.         GUICtrlSetState($textBox1, $GUI_DISABLE)
  39.     EndIf
  40.     ConsoleWrite((TimerDiff($timer) / 1000) & @CRLF)
  41.     ; Timer reaction
  42.     If $timer > 0 And (TimerDiff($timer) / 1000) >= GUICtrlRead($textBox1) Then
  43.         DoSomething()
  44.         ; Set $timer to 0 !!!
  45.         $timer = 0
  46.     EndIf
  47.  
  48.     ; Sleep a while... ^^
  49.     Sleep(50)
  50. WEnd
  51.  
  52. Func DoSomething()
  53.     MsgBox(64, "", "Hm, what to do?")
  54. EndFunc
Add Comment
Please, Sign In to add comment