PcExpert Posted August 6, 2007 Share Posted August 6, 2007 (edited) Hi all, I'm looking for a countdown timer that counts down to zero and starting from a time specified script. I found this code in one of the topics about this: #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 122, 42, 438, 156) $Label1 = GUICtrlCreateLabel("1:00", 8, 8, 43, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $time=TimerInit() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch $new = TimerDiff ($time) $new = (1*60*1000)-$new $seconds = Round ($new/1000) $newMin = Floor ($seconds/60) $newSec = Mod ($seconds, 60) If $newSec < 10 Then $newSec = "0"&$newSec GUICtrlSetData ($Label1, $newMin&":"&$newSec) WEnd But that code doesn't stop at 0:00 . Is there a way to stop it when the countdown is 0:00? thanks! Edited August 6, 2007 by PcExpert Link to comment Share on other sites More sharing options...
jvanegmond Posted August 6, 2007 Share Posted August 6, 2007 You have a long way to go. #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 122, 42, 438, 156) $Label1 = GUICtrlCreateLabel("1:00", 8, 8, 43, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $time = TimerInit() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch $new = (1 * 60 * 1000) - TimerDiff($time) $seconds = Round($new / 1000) $newMin = Floor($seconds / 60) $newSec = Mod($seconds, 60) If $newSec < 10 Then $newSec = "0" & $newSec If ($newMin > 0 Or Number($newSec) > 0) Then GUICtrlSetData($Label1, $newMin & ":" & $newSec) Else GUICtrlSetData($Label1, "0:00") EndIf WEnd github.com/jvanegmond Link to comment Share on other sites More sharing options...
PcExpert Posted August 7, 2007 Author Share Posted August 7, 2007 Bedankt voor de code, Manadar! Link to comment Share on other sites More sharing options...
jvanegmond Posted August 7, 2007 Share Posted August 7, 2007 Bedankt voor de code, Manadar!Geen probleem. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now