Ganz Simpler Countdown

  • Hi Leute, Kann mir jemand einen Simplen Countdown erstellen?

    Es sollte ein GUI Fenster sein indem ein großer Countdown enthalten ist.. man soll Stunden und Minuten einstellen können und wenn der Countdown fertig ist soll eine Meldung mit einem Selbstbetimmbaren Text aufgehen.. so eine Msgbox oder wie die heißen.. nur mit einem OK button

    lg. Zagaris123

  • Quick and dirty:

    Bitte hier klicken
    [autoit='Hier ds Skript']

    Global $time[4]
    #include <GUIConstantsEx.au3>
    $time[3] = 1

    GUICreate("Countdown", 200, 200)
    $STD_E = GUICtrlCreateInput("Std.", 5, 5, 50)
    GUIctrlcreateUpDown($STD_E)
    $MIN_E = GUICtrlCreateInput("Min.", 70, 5, 50)
    GUIctrlcreateUpDown($MIN_E)
    $SEK_E = GUICtrlCreateInput("Sek.", 135, 5, 50)
    GUIctrlcreateUpDown($SEK_E)
    $TEXT = GUICtrlCreateEdit("Hier kommt der Text hin.", 5, 40, 190, 130)
    $START = GUICtrlCreateButton("START! ->", 50, 170)
    GUISetState(@SW_SHOW)
    While 1
    $H = WinGetHandle("Countdown")
    Switch GUIgetMsg($H)
    Case $GUI_EVENT_CLOSE
    Exit
    Case $START
    $time[3] = GUICtrlRead($SEK_E)
    If $time[3] > 0 Then
    $TEXT_Z = GUICtrlRead($TEXT)
    $time[1] = GUICtrlRead($STD_E)
    $time[2] = GUICtrlRead($MIN_E)
    GUIDelete()
    ExitLoop
    ExitLoop
    Else
    MsgBox(0, "", "Du soltest schon mehr als Null eingebn")
    EndIf
    EndSwitch
    WEnd

    GUICreate("Countdown", 200, 60)

    $S = GUICtrlCreateLabel($time[1], 0, 5, 50, 50)
    GUICtrlSetFont($S, 30)
    GUICtrlCreateLabel(":", 50, 5, 30, 60)
    GUICtrlSetFont(-1, 30)
    $M = GUICtrlCreateLabel($time[2], 60, 5, 50, 50)
    GUICtrlSetFont($M, 30)
    GUICtrlCreateLabel(":", 100, 5, 30, 60)
    GUICtrlSetFont(-1, 30)
    $s = GUICtrlCreateLabel($time[3], 115, 5, 50, 50)
    GUICtrlSetFont($s, 30)
    GUISetState(@SW_SHOW)
    sleep(1000)

    While 1
    $time[3] -= 1
    If $time[3] = 0 Then
    $time[2] -= 1
    $time[3] = 60
    $time[0] -= 1
    EndIf
    If $time[2] = 0 and $time[1] > 0 Then
    $time[1] -= 1
    $time[2] = 60
    EndIf
    If $time[2] = 0 and $time[1] = 0 Then
    $time[1] -= 1
    $time[2] = 0
    EndIf
    If $time[3] = 60 and $time[2] = -1 and $time[1] = 0 Then
    GUIDelete()
    sleep(10)
    ExitLoop
    ExitLoop
    EndIf
    GUICtrlSetData($S, $time[1])
    GUICtrlSetData($M, $time[2])
    GUICtrlSetData($s, $time[3])
    sleep(1000)
    WEnd

    MsgBox(0, "Countdown beendet", $TEXT_Z)

    [/autoit]

    Das woltest du doch oder???

  • Hier noch meine simple Version:

    Spoiler anzeigen
    [autoit]


    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $hGUI = GUICreate("Simple Countdown by UEZ 2011", 833, 179)
    GUISetBkColor(0xA6CAF0)
    Global Const $idInputStd = GUICtrlCreateInput("0", 8, 8, 209, 159, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_READONLY,$ES_NUMBER))
    GUICtrlSetFont(-1, 100, 400, 0, "Times New Roman")
    Global Const $idUpdownStd = GUICtrlCreateUpdown($idInputStd)
    GUICtrlSetLimit(-1, 999, 0)
    Global Const $idLableDP1 = GUICtrlCreateLabel(":", 226, 8, 41, 155)
    GUICtrlSetFont(-1, 100, 400, 0, "Times New Roman")
    Global Const $idInputMin = GUICtrlCreateInput("1", 277, 8, 153, 159, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_READONLY,$ES_NUMBER))
    GUICtrlSetFont(-1, 100, 400, 0, "Times New Roman")
    Global Const $idUpdownMin = GUICtrlCreateUpdown($idInputMin)
    GUICtrlSetLimit(-1, 59, 0)
    Global Const $idLableDP2 = GUICtrlCreateLabel(":", 440, 8, 41, 155)
    GUICtrlSetFont(-1, 100, 400, 0, "Times New Roman")
    Global Const $idInputSek = GUICtrlCreateInput("0", 489, 8, 153, 159, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_READONLY,$ES_NUMBER))
    GUICtrlSetFont(-1, 100, 400, 0, "Times New Roman")
    Global Const $idUpdownSek = GUICtrlCreateUpdown($idInputSek)
    GUICtrlSetLimit(-1, 59, 0)
    Global Const $idButtonStart = GUICtrlCreateButton("Start", 672, 8, 147, 113)
    GUICtrlSetFont(-1, 50, 400, 0, "Times New Roman")
    Global Const $idButtonStop = GUICtrlCreateButton("Stop", 672, 136, 147, 33)
    GUICtrlSetFont(-1, 16, 400, 0, "Times New Roman")
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUISetState(@SW_SHOW)
    ControlFocus("", "", $idButtonStart)

    [/autoit] [autoit][/autoit] [autoit]

    Global $nMsg, $seconds

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $idButtonStart
    $seconds = GUICtrlRead($idInputStd) * 60^2 + GUICtrlRead($idInputMin) * 60 + GUICtrlRead($idInputSek) - 1
    If $seconds > 0 Then
    GUICtrlSetState($idButtonStart, $GUI_DISABLE)
    GUICtrlSetState($idUpdownStd, $GUI_DISABLE)
    GUICtrlSetState($idUpdownMin, $GUI_DISABLE)
    GUICtrlSetState($idUpdownSek, $GUI_DISABLE)
    GUICtrlSetState($idButtonStop, $GUI_ENABLE)
    AdlibRegister("Countdown", 1000)
    EndIf
    Case $idButtonStop
    AdlibUnRegister("Countdown")
    GUICtrlSetState($idButtonStart, $GUI_ENABLE)
    GUICtrlSetState($idUpdownStd, $GUI_ENABLE)
    GUICtrlSetState($idUpdownMin, $GUI_ENABLE)
    GUICtrlSetState($idUpdownSek, $GUI_ENABLE)
    GUICtrlSetState($idButtonStop, $GUI_DISABLE)
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func Countdown()
    Local $sec, $min, $hr
    $sec = Mod($seconds, 60)
    $min = Mod($seconds / 60, 60)
    $hr = Floor($seconds / 60 ^ 2)
    GUICtrlSetData($idInputStd, StringFormat("%01i", $hr))
    GUICtrlSetData($idInputMin, StringFormat("%01i", $min))
    GUICtrlSetData($idInputSek, StringFormat("%01i", $sec))
    If $seconds <= 0 Then
    AdlibUnRegister("Countdown")
    MsgBox(0, "Information", "Countdown reached 00:00:00")
    Exit
    EndIf
    $seconds -= 1
    EndFunc

    [/autoit]

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯