#include #include #include #include Global $g_bPaused = False HotKeySet("6D", "GoBack") HotKeySet("{PAUSE}", "TogglePause") Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Global $SS_CENTER, $_Countdown = 15000, $_Minutes, $_Seconds Local $_GuiCountDown = GUICreate ( "HT Conditioning Timer", 420, 115, @DesktopWidth -432, @DesktopHeight -185 ) GUISetBkColor ( 0x336699 ) GUISetState(@SW_SHOW, $_GuiCountDown) $TimeLabel = GUICtrlCreateLabel ( "", 35, 0, 480, 180, $SS_CENTER ) GUICtrlSetFont ( -1, 50, 800 ,1, "Arial", 5) GUICtrlSetColor ( $TimeLabel, 0xffffff ) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEButton") $idPause = GUICtrlCreateButton("Pause", 175, 80, 70, 25) $idMinus = GUICtrlCreateButton("<", 145, 80, 25, 25) $idPlus = GUICtrlCreateButton(">", 250, 80, 25, 25) WinSetOnTop ( $_GuiCountDown, "", 1 ) $TimeTicks = TimerInit ( ) $kV = 1 $StepSize = 16000 While 1 _Check ( ) Sleep (1) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $idMinus $kV = $kV - 1 Case $msg = $idPause TogglePause() EndSelect WEnd Func CLOSEButton() Exit EndFunc ;==>CLOSEButton Func TogglePause() $g_bPaused = Not $g_bPaused While $g_bPaused Sleep(100) $TimeTicks = TimerInit ( ) WEnd EndFunc ;==>TogglePause Func GoBack() If _IsPressed ("6D") Then While Sleep(1000) $kV = $kV + 1 WEnd EndIf EndFunc ;==>GoBack Func _Check ( ) $_Countdown -= TimerDiff ( $TimeTicks ) $TimeTicks = TimerInit ( ) Local $_MinCalc = Int ( $_Countdown / ( 60 * 1000 ) ), $_SecCalc = $_Countdown - ( $_MinCalc * 60 * 1000 ) $_SecCalc = Int ( $_SecCalc / 1000 ) If $_MinCalc <> $_Minutes Or $_SecCalc <> $_Seconds Then $_Minutes = $_MinCalc $_Seconds = $_SecCalc If $kV < 10 Then $Voltage = " " & $kV Else $Voltage = $kV EndIf GUICtrlSetData ( $TimeLabel, StringFormat ( $Voltage & "kV " & "%02u" & ":" & "%02u", $_Minutes, $_Seconds ) ) If $_Minutes = 0 And $_Seconds <= 3 Then GUISetBkColor ( 0xFF3333 ) If $_Minutes = 0 And $_Seconds > 0 Then Beep ( 1200, 300 ) EndIf If $_Minutes = 0 And $_Seconds <= 0 Then $kV = $kV + (1) $_Countdown = $StepSize Beep ( 1000, 1000 ) GUISetBkColor ( 0x336699 ) If $kV = 14 Then $StepSize = 61000 EndIf If $kV = 24 Then $StepSize = 181000 EndIf If $kV = 29 Then $StepSize = 301000 EndIf If $kV = 35 Then $StepSize = 3601000 EndIf If $kV = 36 And $_Minutes = 0 And $_Seconds <= 0 Then GUISetBkColor ( 0xcccc33 ) EndIf If $kV >= 37 And $_Minutes = 0 And $_Seconds <= 0 Then GUISetBkColor ( 0x33cc33 ) GUICtrlSetData ( $TimeLabel, " Complete!" ) While 1 Sleep (100); just sleeps forever.... WEnd EndIf EndIf EndIf EndIf EndFunc ;==> _Check ( )