Search the Community
Showing results for tags 'power hour'.
-
I'm having an issue with my countdown timer. It will no longer countdown and it seems like it is blinking rapidly. I'm pretty sure it is due to the way I did $_HourCalc, since I couldn't find an example with that in it. I should also add that this is someone else's (niksigouin) script that I modified for my own use. I was wondering if anyone could help me out on the HourCalc or why it won't count down any longer. #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $_CompteArebour =0, $_Hours, $_Minutes, $_Seconds $TimeTicks = TimerInit() $Form1 = GUICreate("ImproTimer", 946, 535, -1, -1) $TimerLabel = GUICtrlCreateLabel("", 352, 40, 247, 125, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetData($TimerLabel, StringFormat("%02u" & ":" & "%02u" & ":" & "%02u", $_Hours, $_Minutes, $_Seconds)) GUICtrlSetFont($TimerLabel, 72, 400, 0, "MS Sans Serif") $BtnStart = GUICtrlCreateButton("Start", 352, 168, 121, 33) $BtnPause = GUICtrlCreateButton("Pause", 352, 168, 121, 33) GUICtrlSetState(-1, $GUI_HIDE) $BtnReset = GUICtrlCreateButton("Reset", 480, 168, 121, 33) $BtnAdd60 = GUICtrlCreateButton("60", 352, 208, 57, 33) $BtnAdd30 = GUICtrlCreateButton("100", 416, 208, 57, 33) $BtnAdd10 = GUICtrlCreateButton("120", 480, 208, 57, 33) $BtnAdd5 = GUICtrlCreateButton("180", 544, 208, 57, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $BtnStart ;<=== When pressed "Start", hide and then show "Pause" GUICtrlSetState($BtnStart, $GUI_HIDE) GUICtrlSetState($BtnPause, $GUI_SHOW) _Run() Case $BtnAdd60 ;=== Add 1 minute to the Timer $_CompteArebour = $_CompteArebour + (60000 * 60) GUICtrlSetState($BtnStart, $GUI_HIDE) GUICtrlSetState($BtnPause, $GUI_SHOW) _Run() Case $BtnAdd30 ;=== Add 30 seconds to the Timer $_CompteArebour = $_CompteArebour + (100000 * 60) GUICtrlSetState($BtnStart, $GUI_HIDE) GUICtrlSetState($BtnPause, $GUI_SHOW) _Run() Case $BtnAdd10 ;=== Add 10 seconds to the Timer $_CompteArebour = $_CompteArebour + (120000 * 60) GUICtrlSetState($BtnStart, $GUI_HIDE) GUICtrlSetState($BtnPause, $GUI_SHOW) _Run() Case $BtnAdd5 ;=== Add 5 seconds to the Timer $_CompteArebour = $_CompteArebour + (180000 * 60) GUICtrlSetState($BtnStart, $GUI_HIDE) GUICtrlSetState($BtnPause, $GUI_SHOW) _Run() Case $BtnReset ;=== Reset the Timer to 00:00 $_CompteArebour = 0 GUICtrlSetData($TimerLabel, StringFormat("%02u" & ":" & "%02u" & ":" & "%02u", 0, 0, 0)) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _Run() While 1 _Check() WEnd EndFunc ;==>_Run Func _Check() ;==> A function I took from an other example hoping to get an input to work $nMsg = GUIGetMsg() Switch $nMsg Case $BtnStart ;<=== When pressed "Start", hide and then show "Pause" GUICtrlSetState($BtnStart, $GUI_HIDE) GUICtrlSetState($BtnPause, $GUI_SHOW) _Run() Case $BtnPause ;<=== When pressed "Pause" hide and then show "Start" GUICtrlSetState($BtnPause, $GUI_HIDE) GUICtrlSetState($BtnStart, $GUI_SHOW) Case $BtnAdd60 ;=== Add 1 minute to the Timer $_CompteArebour = $_CompteArebour + 3600000 Case $BtnAdd30 ;=== Add 30 seconds to the Timer $_CompteArebour = $_CompteArebour + 6000000 Case $BtnAdd10 ;=== Add 10 seconds to the Timer $_CompteArebour = $_CompteArebour + 7200000 Case $BtnAdd5 ;=== Add 5 seconds to the Timer $_CompteArebour = $_CompteArebour + 10800000 Case $BtnReset ;=== Reset the Timer to 00:00 $_CompteArebour = 0 GUICtrlSetData($TimerLabel, StringFormat("%02u" & ":" & "%02u" & ":" & "%02u", $_Hours, $_Minutes, $_Seconds)) Case $GUI_EVENT_CLOSE Exit EndSwitch Local $_HourCalc = Int($_CompteArebour / (3600000)), $_MinCalc = $_CompteArebour / 60000 - ($_HourCalc * 60), $_SecCalc = $_CompteArebour - ($_MinCalc * 60 * 1000) $_SecCalc = Int($_SecCalc / 1000000) $_CompteArebour -= TimerDiff($TimeTicks) $TimeTicks = TimerInit() Local $_HourCalc = Int($_CompteArebour / (3600000)), $_MinCalc = $_CompteArebour / 60000 - ($_HourCalc * 60), $_SecCalc = $_CompteArebour - ($_MinCalc * 60 * 1000) $_SecCalc = Int($_SecCalc / 1000000) If $_HourCalc <= 0 And $_MinCalc <= 0 And $_SecCalc <= 0 Then GUISetBkColor(0xFF0000, $Form1) GUICtrlSetData($TimerLabel, "Power!") Sleep(1000) GUICtrlSetData($TimerLabel, StringFormat("%02u" & ":" & "%02u" & ":" & "%02u", $_Hours, $_Minutes, $_Seconds)) ; If @Compiled Then Shutdown ( 13 ) Else If $_HourCalc <> $_Hours Or $_MinCalc <> $_Minutes Or $_SecCalc <> $_Seconds Then $_Hours = $_HourCalc $_Minutes = $_MinCalc $_Seconds = $_SecCalc GUICtrlSetData($TimerLabel, StringFormat("%02u" & ":" & "%02u" & ":" & "%02u", $_Hours, $_Minutes, $_Seconds)) If $_Hours = 0 And $_Minutes = 0 And $_Seconds <= 10 Then Beep(1200, 100) GUISetBkColor(0xA093FF, $Form1) EndIf EndIf EndIf EndFunc ;==>_Check