#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <Date.au3>
$hGUI = GUICreate('Starter', 736, 294, 1476, 138)
$hInTime_1 = GUICtrlCreateInput('HH.MM.SS', 24, 24, 121, 21)
$hOutTime_1 = GUICtrlCreateInput('', 168, 24, 129, 21, $ES_READONLY)
$hCombo_1 = GUICtrlCreateCombo('1', 312, 24, 145, 21)
GUICtrlSetData(-1, '2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30', '1')
$hCheck_1 = GUICtrlCreateCheckbox('AutoRepeat', 472, 24, 81, 25)
$hStart_1 = GUICtrlCreateButton('Start 1', 576, 16, 105, 25, $WS_GROUP)
Global $iRepeat_1 = 0, $Stop_1 = False
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $hStart_1
$sTime_1 = GUICtrlRead($hInTime_1)
If StringRegExp($sTime_1, '^\d\d\.\d\d\.\d\d$') Then
$aTime_1 = StringSplit(GUICtrlRead($hInTime_1), '.')
$iHour_1 = $aTime_1[1]
$iMin_1 = $aTime_1[2]
$iSec_1 = $aTime_1[3]
If GUICtrlRead($hCheck_1) = $GUI_CHECKED Then
$iRepeat_1 = 0
Else
$iRepeat_1 = GUICtrlRead($hCombo_1)
EndIf
GUICtrlSetData($hStart_1, 'Stop 1')
GUICtrlSetState($hInTime_1, $GUI_DISABLE)
GUICtrlSetState($hCheck_1, $GUI_DISABLE)
GUICtrlSetState($hCombo_1, $GUI_DISABLE)
Opt('GUIOnEventMode', 1)
$Stop_1 = False
GUICtrlSetOnEvent($hStart_1, '_stop')
_main_1($iRepeat_1, $iHour_1, $iMin_1, $iSec_1)
Opt('GUIOnEventMode', 0)
GUICtrlSetData($hStart_1, 'Start 1')
GUICtrlSetState($hInTime_1, $GUI_ENABLE)
GUICtrlSetState($hCheck_1, $GUI_ENABLE)
GUICtrlSetState($hCombo_1, $GUI_ENABLE)
Else
MsgBox(0, 'Error', 'Error in time format!')
EndIf
Case $hCheck_1
If GUICtrlRead($hCheck_1) = $GUI_CHECKED Then
GUICtrlSetState($hCombo_1, $GUI_DISABLE)
Else
GUICtrlSetState($hCombo_1, $GUI_ENABLE)
EndIf
EndSwitch
WEnd
Func _main_1($iReapeatCounter, $iHour, $iMin, $iSec)
$iCounter = 0
_TicksToTime(_TimeToTicks($iHour + @HOUR, $iMin + @MIN, $iSec + @SEC), $iHour, $iMin, $iSec)
GUICtrlSetData($hOutTime_1, $iHour & ':' & $iMin & ':' & $iSec)
ConsoleWrite('-TIME WAITING-' & @CRLF)
Do
If $Stop_1 Then Return
Sleep(1000)
Until $iHour - @HOUR <= 0 And $iMin - @MIN <= 0 And $iSec - @SEC <= 0
ConsoleWrite('!START!' & @CRLF)
Do
ConsoleWrite('working...' & $iCounter & @CRLF)
Sleep(500)
$iCounter += 1
Until $iReapeatCounter = $iCounter Or $Stop_1 = True
ConsoleWrite('+FINISH+' & @CRLF)
GUICtrlSetData($hOutTime_1, '')
EndFunc
Func _stop()
If @GUI_CtrlId = $hStart_1 Then
$Stop_1 = True
EndIf
EndFunc