Zen Posted January 6, 2006 Posted January 6, 2006 I want a Countdown-Timer. You tipp in the Edit-Box a Time like "01:20:47". The Script make 01 = 1 Hour 20 = 20 Minutes 47 = 47 Seconds Then a SplashTextOn comes and make the Countdown with this Time. expandcollapse popup#include <GuiConstants.au3> AutoItSetOption("GUIOnEventMode", 1) If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 $mainwindow = GuiCreate("MyGUI", 340, 256,(@DesktopWidth-340)/2, (@DesktopHeight-256)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) GUISetOnEvent($GUI_EVENT_CLOSE, "Beenden") $Edit_7 = GuiCtrlCreateEdit("10:16:03", 10, 80, 210, 170) $Button_8 = GuiCtrlCreateButton("Berechnen", 240, 170, 90, 40) GUICtrlSetOnEvent($Button_8, "Berechnen") GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() WEnd Func Berechnen() $ZeitRead = GUICtrlRead($Edit_7) $ZeitTrennung = StringSplit($ZeitRead, ":") $Stunden = $ZeitTrennung[1] $Minuten = $ZeitTrennung[2] $Sekunden = $ZeitTrennung[3] SplashTextOn("Countdown", "", 240, 50, 25, 800, 0, 0, 15, 500) For $Std = $Stunden To 1 Step - 1 $messageStd = $Std For $min = $Minuten To 1 Step - 1 $messageMin = $min For $sek = $Sekunden To 1 Step - 1 $messageSek = $sek ControlSetText("Countdown", "", "Static1", $messageStd & " Std " & $messageMin & " Min " & $messageSek & " Sek") Sleep(1000) $messageSek = "" Next $messageMin = "" Next $messageStd = "" Next ControlSetText("Countdown", "", "Static1", "Fertig!") SplashOff() EndFunc Func Beenden() If @GUI_WinHandle = $mainwindow Then Exit EndIf EndFunc ;==>Beenden The Problem is, when the first Seconds are finished, the next Minuten are not 60 seconds. I have no idea, how i can fix this. Can anybody help me? Please Zen
GaryFrost Posted January 7, 2006 Posted January 7, 2006 (edited) expandcollapse popup#include <GuiConstants.au3> AutoItSetOption("GUIOnEventMode", 1) If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 $mainwindow = GUICreate("MyGUI", 340, 256, (@DesktopWidth - 340) / 2, (@DesktopHeight - 256) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) GUISetOnEvent($GUI_EVENT_CLOSE, "Beenden") $Edit_7 = GUICtrlCreateEdit("10:16:03", 10, 80, 210, 170) $Button_8 = GUICtrlCreateButton("Berechnen", 240, 170, 90, 40) GUICtrlSetOnEvent($Button_8, "Berechnen") $Button_9 = GUICtrlCreateButton("Stop", 240, 220, 90, 40) GUICtrlSetOnEvent($Button_9, "_Stop") GUISetState() $countdown = 0 While 1 Sleep(10) If $countdown Then $ZeitRead = GUICtrlRead($Edit_7) $ZeitTrennung = StringSplit($ZeitRead, ":") $Stunden = $ZeitTrennung[1] $Minuten = $ZeitTrennung[2] $Sekunden = $ZeitTrennung[3] SplashTextOn("Countdown", "", 240, 50, 10, 10, 0, "", 15, 500) For $Std = $Stunden To 1 Step - 1 If $countdown = 0 Then ExitLoop $messageStd = $Std For $min = $Minuten To 1 Step - 1 If $countdown = 0 Then ExitLoop $messageMin = $min For $sek = $Sekunden To 1 Step - 1 If $countdown = 0 Then ExitLoop $messageSek = $sek ControlSetText("Countdown", "", "Static1", $messageStd & " Std " & $messageMin & " Min " & $messageSek & " Sek") ControlSetText($mainwindow, "", "Edit1", $messageStd & ":" & $messageMin & ":" & $messageSek) Sleep(1000) $messageSek = "" Next $messageMin = "" $Sekunden = 60 Next $messageStd = "" Next ControlSetText("Countdown", "", "Static1", "Fertig!") SplashOff() EndIf WEnd Func Berechnen() $countdown = 1 EndFunc ;==>Berechnen Func _Stop() $countdown = 0 EndFunc ;==>_Stop Func Beenden() If @GUI_WinHandle = $mainwindow Then Exit EndIf EndFunc ;==>Beenden Edited January 7, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Zen Posted January 7, 2006 Author Posted January 7, 2006 (edited) Thank you very much! .:EDIT:. I have found one Problem. When the time is down to 1:1:1, the time doesn't go down and all stop. The Stop-Button is very cool Edited January 7, 2006 by Zen
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