Problem mit Function / Timer

  • Hallo zusammen,

    ich versuche mir einen Timer zu basteln, dank der _countdown Funktion von bugfix hab ich es nun auch soweit hinbekommen.

    Beim ersten Start funktioniert das ganze soweit bereits wie es soll.
    Jetzt wollte ich das ganze noch soweit modifizieren das man die Timer Zeit mittels einer extra GUI ändern kann. Und da beginnt nun mein Problem, sobald die Änderung mittels Button abgeschickt wird und der Timer erfolgreich neu startet, funktioniert keine der anderen Dinge in der GUI.
    Edit/Stop/Close und ebenso das bewegen des Fensters ist dann nicht mehr möglich.

    Hoffe ich konnte mein Problem annähernd beschreiben :)

    Danke

    Spoiler anzeigen
    [autoit]

    #include <APIConstants.au3>
    #include <Date.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>

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

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)

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

    Local $tGUI, $tLabel_timer
    Local $WinXPos, $WinYPos, $WinPos
    Local $sGUI, $iH, $iM, $iS
    Local $sec = 0, $min = 10, $hr = 0, $stopit = 0
    Local $inifile = @ScriptDir & "\MyTimer.ini"

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

    _showTimer()

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

    While 1
    Sleep(100)
    WEnd

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

    ; #FUNCTION# ===================================================================
    ; Description ...: show timer window
    ; ==============================================================================
    Func _showTimer()
    $tGUI = GUICreate("Timer", 300, 82, -1, -1, $WS_POPUP)
    GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_PrimeDown")
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseApp")
    $tLabel_timer = GUICtrlCreateLabel("00:00:00 h", 0, 17, 300, 65, $SS_CENTER)
    GUICtrlSetBkColor(-1, 0xBFCDDB)
    GUICtrlSetColor(-1, 0x0000FF)
    GUICtrlSetFont(-1, 40, 400, 0, "Roland")
    GUICtrlCreateLabel("[Edit]", 0, 1, 30, 15)
    GUICtrlSetOnEvent(-1, "_showSetup")
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUICtrlCreateLabel("[Stop]", (300 / 2) - 17, 1, 34, 15)
    GUICtrlSetOnEvent(-1, "_stopTimer")
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUICtrlCreateLabel("[Close]", 259, 1, 40, 15, $SS_RIGHT)
    GUICtrlSetOnEvent(-1, "_closeApp")
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    ; alte Fensterposition laden und GUI verschieben
    If $inifile <> "" Then
    $WinXPos = IniRead($inifile, "Startwerte", "WinXPos", "")
    $WinYPos = IniRead($inifile, "Startwerte", "WinYPos", "")
    If $WinXPos <> "" And $WinYPos <> "" Then WinMove("Timer", "", $WinXPos, $WinYPos)
    EndIf
    _startCountDown()
    EndFunc ;==>_showTimer

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

    ; #FUNCTION# ===================================================================
    ; Description ...: show Setup window
    ; ==============================================================================
    Func _ShowSetup()
    _stopTimer()
    $sGUI = GUICreate("Settings", 256, 205, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseSetup")
    GUICtrlCreateLabel('Stunden', 15, 48, 60, 17)
    $iH = GUICtrlCreateInput('', 80, 45, 20, 20, $ES_NUMBER)
    GUICtrlCreateLabel('Minuten', 15, 78, 60, 17)
    $iM = GUICtrlCreateInput('', 80, 75, 20, 20, $ES_NUMBER)
    GUICtrlCreateLabel('Sekunden', 15, 108, 60, 17)
    $iS = GUICtrlCreateInput('', 80, 105, 20, 20, $ES_NUMBER)
    GUICtrlCreateButton('Change time', 140, 15, 105, 25)
    GUICtrlSetOnEvent(-1, "_closeSetup")
    GUISetState(@SW_SHOW)
    EndFunc ;==>_ShowSetup

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

    ; #FUNCTION# ===================================================================
    ; Description ...: Close setup window
    ; ==============================================================================
    Func _CloseSetup()
    If GUICtrlRead($iH) = '' Then
    $hr = 0
    Else
    $hr = GUICtrlRead($iH)
    EndIf
    If GUICtrlRead($iM) = '' Then
    $min = 0
    Else
    $min = GUICtrlRead($iM)
    EndIf
    If GUICtrlRead($iS) = '' Then
    $sec = 0
    Else
    $sec = GUICtrlRead($iS)
    EndIf
    ConsoleWrite("H: " & $hr & @CRLF & "M: " & $min & @CRLF & "S: " & $sec & @CRLF)
    GUIDelete($sGUI)
    _startCountDown()

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

    EndFunc ;==>_CloseSetup

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

    ; #FUNCTION# ===================================================================
    ; Description ...: close App and write position to ini file
    ; ==============================================================================
    Func _CloseApp()
    IniDelete($inifile, "Startwerte")
    $WinPos = WinGetPos("Timer")
    IniWrite($inifile, "Startwerte", "WinXPos", $WinPos[0])
    IniWrite($inifile, "Startwerte", "WinYPos", $WinPos[1])
    Exit
    EndFunc ;==>_CloseApp

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

    ; #FUNCTION# ===================================================================
    ; Description ...: Start Countdown
    ; ==============================================================================
    Func _startCountDown()
    _CountDown($sec, $min, $hr, 0, True, $tLabel_timer)
    EndFunc ;==>_startCountDown

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

    ; #FUNCTION# ===================================================================
    ; Description ...: Stop Timer
    ; ==============================================================================
    Func _stopTimer()
    $stopit = 1
    EndFunc ;==>_stopTimer

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

    ; #FUNCTION# ===================================================================
    ; Description ...: makes GUI moveable with mouse
    ; ==============================================================================
    Func _PrimeDown()
    Local $DifX, $DifY, $MouseData = GUIGetCursorInfo(@GUI_WinHandle)
    Local $WinPos = WinGetPos(@GUI_WinHandle)
    Local $MPos = MouseGetPos()
    $DifX = $MPos[0] - $WinPos[0]
    $DifY = $MPos[1] - $WinPos[1]
    While $MouseData[2]
    $MPos = MouseGetPos()
    $WinPos = WinGetPos(@GUI_WinHandle)
    If ($WinPos[0] <> ($MPos[0] - $DifX)) Or ($WinPos[1] <> ($MPos[1] - $DifY)) Then
    WinMove(@GUI_WinHandle, '', $MPos[0] - $DifX, $MPos[1] - $DifY)
    EndIf
    Sleep(15)
    $MouseData = GUIGetCursorInfo(@GUI_WinHandle)
    WEnd
    ;GUICtrlSetState($suchtext_id,$GUI_FOCUS)
    EndFunc ;==>_PrimeDown

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

    ;----------------------------------------------------------------------------------------------------------------------
    ; Funktion _CountDown($SEC [, $MIN=0 [, $HOUR=0 [, $DAY=0 [, $VISIBLEDOWN=True [, $ALTERNATECTRL='TT']]]]])
    ;
    ; Beschreibung zählt vorgegebene Zeitspanne (Tage, Stunden, Minuten, Sekunden) herunter mit Anzeige Tooltip (Standard)
    ; oder Ausgabe in GUI-Ctrl; wahlweise Anzeige von Restzeit (Standard) oder abgelaufener Zeit
    ;
    ; Parameter $SEC: Sekunden
    ; optional $MIN: Minuten
    ; optional $HOUR: Stunden
    ; optional $DAY: Tage
    ; optional $VISIBLEDOWN: Ansicht (herunterzählen/heraufzählen)
    ; optional $ALTERNATECTRL: GUI-Ctrl in das die Ausgabe mittels GUICtrlSetData() ausgegeben wird
    ;
    ; Erfordernisse #include <Date.au3>
    ;
    ; Autor BugFix ([email='bugfix@autoit.de'][/email])
    ;----------------------------------------------------------------------------------------------------------------------
    Func _CountDown($sec, $min = 0, $HOUR = 0, $day = 0, $VISIBLEDOWN = True, $ALTERNATECTRL = 'TT')
    Local $Sekunden, $secShow, $end
    $Sekunden = $sec + $min * 60 + $HOUR * 3600 + $day * 86400
    $end = _DateAdd('s', $Sekunden, _NowCalc())
    Local $message
    Do
    Sleep(100)
    $sec = _DateDiff('s', _NowCalc(), $end)
    If Not $VISIBLEDOWN Then
    $secShow = $Sekunden - $sec
    Else
    $secShow = $sec
    EndIf
    Select
    Case $secShow < 60
    If $ALTERNATECTRL = 'TT' Then
    ToolTip(StringFormat('%02u', $secShow) & ' s')
    Else
    GUICtrlSetData($ALTERNATECTRL, StringFormat('%02u', $secShow) & ' s')
    EndIf
    Case $secShow < 60 * 60
    $message = StringFormat('%02u', Floor($secShow / 60)) & ':' & _
    StringFormat('%02u', Mod($secShow, 60)) & ' min'
    If $ALTERNATECTRL = 'TT' Then
    ToolTip($message)
    Else
    GUICtrlSetData($ALTERNATECTRL, $message)
    EndIf
    Case $secShow < 60 * 60 * 24
    $message = StringFormat('%02u', Floor($secShow / 3600)) & ':' & _
    StringFormat('%02u', Floor(Mod($secShow, 3600) / 60)) & ':' & _
    StringFormat('%02u', Mod(Mod($secShow, 3600), 60)) & ' h'
    If $ALTERNATECTRL = 'TT' Then
    ToolTip($message)
    Else
    GUICtrlSetData($ALTERNATECTRL, $message)
    EndIf
    Case Else
    $message = Floor($secShow / 86400) & ' d / ' & _
    StringFormat('%02u', Floor(Mod($secShow, 86400) / 3600)) & ':' & _
    StringFormat('%02u', Floor(Mod(Mod($secShow, 86400), 3600) / 60)) & ':' & _
    StringFormat('%02u', Mod(Mod(Mod($secShow, 86400), 3600), 60)) & ' h'
    If $ALTERNATECTRL = 'TT' Then
    ToolTip($message)
    Else
    GUICtrlSetData($ALTERNATECTRL, $message)
    EndIf
    EndSelect

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

    Until $sec = 0 Or $stopit = 1
    $stopit = 0
    #cs
    If $sec = 0 Then
    GUICtrlSetData($tLabel_timer, " It's time")
    SoundPlay(@ScriptDir & "\alarma.wav", 1)
    EndIf
    #ce
    EndFunc ;==>_CountDown

    [/autoit]


    Gruß Mks

    Einmal editiert, zuletzt von mks (11. April 2013 um 20:54)

  • Hallo mks,

    die Beschreibung Deines Problems lässt vermuten, dass sich Dein Script, nachdem der beschriebene Ablauf beendet ist, in einer (Endlos-)Schleife (u. U. Z. 18-20) befindet, die "verhindert", dass das GUI abgefragt wird.
    Da Du bereits den GUIOnEventMode verwendest, solltest Du überprüfen, ob dieser auch "richtig" verwendet wird (s. dazu entsprechender Eintrag in der Hilfe). Auch Ereignisse müssen als solche (für das Script) erkennbar sein.

    • Offizieller Beitrag

    Das wird niemals so funtionieren.
    Wenn die Funktion _startCountDown() normal aus dem Hauptscript aufgerufen wird, funzt sie.
    Wenn sie aus einer Funktion aufgerufen wird, welche einem Event zugeordnet ist, dann blockiert sie das ganze Eventsystem.

    [autoit]

    Func _CloseSetup()
    If GUICtrlRead($iH) = '' Then
    $hr = 0
    Else
    $hr = GUICtrlRead($iH)
    EndIf
    If GUICtrlRead($iM) = '' Then
    $min = 0
    Else
    $min = GUICtrlRead($iM)
    EndIf
    If GUICtrlRead($iS) = '' Then
    $sec = 0
    Else
    $sec = GUICtrlRead($iS)
    EndIf
    ConsoleWrite("H: " & $hr & @CRLF & "M: " & $min & @CRLF & "S: " & $sec & @CRLF)
    GUIDelete($sGUI)
    _startCountDown()

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

    EndFunc ;==>_CloseSetup

    [/autoit]


    In Zeile 19 wird in die Timerfunktion gesprungen und erst nach dem Ablauf des Timers zurückgekehrt.
    Die Funktion _CloseSetup wird also erst nach dem Timer verlassen, solange die Funktion läuft, kann aber keine weitere Event Funktion aufgerufen werden.

    Edit: Wenn AutoIt nicht will, muß man es halt zwingen. Deshalb mißbrauchen wir mal eben AdlibRegister dazu eine Funktion versetzt zu starten. :D

    Spoiler anzeigen
    [autoit]

    #Region - Timestamp
    ; 2013-04-11 20:22:45
    #EndRegion

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

    #include <APIConstants.au3>
    #include <Date.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>

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

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)

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

    Local $tGUI, $tLabel_timer
    Local $WinXPos, $WinYPos, $WinPos
    Local $sGUI, $iH, $iM, $iS
    Local $sec = 0, $min = 10, $hr = 0, $stopit = 0
    Local $inifile = @ScriptDir & "\MyTimer.ini"

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

    _showTimer()

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

    While 1
    Sleep(100)
    WEnd

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

    ; #FUNCTION# ===================================================================
    ; Description ...: show timer window
    ; ==============================================================================
    Func _showTimer()
    $tGUI = GUICreate("Timer", 300, 82, -1, -1, $WS_POPUP)
    GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_PrimeDown")
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseApp")
    $tLabel_timer = GUICtrlCreateLabel("00:00:00 h", 0, 17, 300, 65, $SS_CENTER)
    GUICtrlSetBkColor(-1, 0xBFCDDB)
    GUICtrlSetColor(-1, 0x0000FF)
    GUICtrlSetFont(-1, 40, 400, 0, "Roland")
    GUICtrlCreateLabel("[Edit]", 0, 1, 30, 15)
    GUICtrlSetOnEvent(-1, "_showSetup")
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUICtrlCreateLabel("[Stop]", (300 / 2) - 17, 1, 34, 15)
    GUICtrlSetOnEvent(-1, "_stopTimer")
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUICtrlCreateLabel("[Close]", 259, 1, 40, 15, $SS_RIGHT)
    GUICtrlSetOnEvent(-1, "_closeApp")
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    ; alte Fensterposition laden und GUI verschieben
    If $inifile <> "" Then
    $WinXPos = IniRead($inifile, "Startwerte", "WinXPos", "")
    $WinYPos = IniRead($inifile, "Startwerte", "WinYPos", "")
    If $WinXPos <> "" And $WinYPos <> "" Then WinMove("Timer", "", $WinXPos, $WinYPos)
    EndIf
    _startCountDown()
    EndFunc ;==>_showTimer

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

    ; #FUNCTION# ===================================================================
    ; Description ...: show Setup window
    ; ==============================================================================
    Func _ShowSetup()
    _stopTimer()
    $sGUI = GUICreate("Settings", 256, 205, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseSetup")
    GUICtrlCreateLabel('Stunden', 15, 48, 60, 17)
    $iH = GUICtrlCreateInput('', 80, 45, 20, 20, $ES_NUMBER)
    GUICtrlCreateLabel('Minuten', 15, 78, 60, 17)
    $iM = GUICtrlCreateInput('', 80, 75, 20, 20, $ES_NUMBER)
    GUICtrlCreateLabel('Sekunden', 15, 108, 60, 17)
    $iS = GUICtrlCreateInput('', 80, 105, 20, 20, $ES_NUMBER)
    GUICtrlCreateButton('Change time', 140, 15, 105, 25)
    GUICtrlSetOnEvent(-1, "_closeSetup")
    GUISetState(@SW_SHOW)
    EndFunc ;==>_ShowSetup

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

    ; #FUNCTION# ===================================================================
    ; Description ...: Close setup window
    ; ==============================================================================
    Func _CloseSetup()
    If GUICtrlRead($iH) = '' Then
    $hr = 0
    Else
    $hr = GUICtrlRead($iH)
    EndIf
    If GUICtrlRead($iM) = '' Then
    $min = 0
    Else
    $min = GUICtrlRead($iM)
    EndIf
    If GUICtrlRead($iS) = '' Then
    $sec = 0
    Else
    $sec = GUICtrlRead($iS)
    EndIf
    ConsoleWrite("H: " & $hr & @CRLF & "M: " & $min & @CRLF & "S: " & $sec & @CRLF)
    GUIDelete($sGUI)
    AdlibRegister("_startCountDown",200); Die Funktion _startCountDown wird über AdlibRegister aufgerufen, somit kann die Function _CloseSetup sofort beendet werden und die Events werden ordnungsgemäß weiterverarbeitet

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

    EndFunc ;==>_CloseSetup

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

    ; #FUNCTION# ===================================================================
    ; Description ...: close App and write position to ini file
    ; ==============================================================================
    Func _CloseApp()
    IniDelete($inifile, "Startwerte")
    $WinPos = WinGetPos("Timer")
    IniWrite($inifile, "Startwerte", "WinXPos", $WinPos[0])
    IniWrite($inifile, "Startwerte", "WinYPos", $WinPos[1])
    Exit
    EndFunc ;==>_CloseApp

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

    ; #FUNCTION# ===================================================================
    ; Description ...: Start Countdown
    ; ==============================================================================
    Func _startCountDown()
    AdlibUnRegister("_startCountDown"); AdlibUnregistrieren, damit die Funktion nicht alle 200 ms aufgerufen wird. Der Adlib dient nur dazu die Function _CloseSetup so schnell als möglich zu verlassen.
    _CountDown($sec, $min, $hr, 0, True, $tLabel_timer)
    EndFunc ;==>_startCountDown

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

    ; #FUNCTION# ===================================================================
    ; Description ...: Stop Timer
    ; ==============================================================================
    Func _stopTimer()
    $stopit = 1
    EndFunc ;==>_stopTimer

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

    ; #FUNCTION# ===================================================================
    ; Description ...: makes GUI moveable with mouse
    ; ==============================================================================
    Func _PrimeDown()
    Local $DifX, $DifY, $MouseData = GUIGetCursorInfo(@GUI_WinHandle)
    Local $WinPos = WinGetPos(@GUI_WinHandle)
    Local $MPos = MouseGetPos()
    $DifX = $MPos[0] - $WinPos[0]
    $DifY = $MPos[1] - $WinPos[1]
    While $MouseData[2]
    $MPos = MouseGetPos()
    $WinPos = WinGetPos(@GUI_WinHandle)
    If ($WinPos[0] <> ($MPos[0] - $DifX)) Or ($WinPos[1] <> ($MPos[1] - $DifY)) Then
    WinMove(@GUI_WinHandle, '', $MPos[0] - $DifX, $MPos[1] - $DifY)
    EndIf
    Sleep(15)
    $MouseData = GUIGetCursorInfo(@GUI_WinHandle)
    WEnd
    ;GUICtrlSetState($suchtext_id,$GUI_FOCUS)
    EndFunc ;==>_PrimeDown

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

    ;----------------------------------------------------------------------------------------------------------------------
    ; Funktion _CountDown($SEC [, $MIN=0 [, $HOUR=0 [, $DAY=0 [, $VISIBLEDOWN=True [, $ALTERNATECTRL='TT']]]]])
    ;
    ; Beschreibung zählt vorgegebene Zeitspanne (Tage, Stunden, Minuten, Sekunden) herunter mit Anzeige Tooltip (Standard)
    ; oder Ausgabe in GUI-Ctrl; wahlweise Anzeige von Restzeit (Standard) oder abgelaufener Zeit
    ;
    ; Parameter $SEC: Sekunden
    ; optional $MIN: Minuten
    ; optional $HOUR: Stunden
    ; optional $DAY: Tage
    ; optional $VISIBLEDOWN: Ansicht (herunterzählen/heraufzählen)
    ; optional $ALTERNATECTRL: GUI-Ctrl in das die Ausgabe mittels GUICtrlSetData() ausgegeben wird
    ;
    ; Erfordernisse #include <Date.au3>
    ;
    ; Autor BugFix ([email='bugfix@autoit.de'][/email])
    ;----------------------------------------------------------------------------------------------------------------------
    Func _CountDown($sec, $min = 0, $HOUR = 0, $day = 0, $VISIBLEDOWN = True, $ALTERNATECTRL = 'TT')
    Local $Sekunden, $secShow, $end
    $Sekunden = $sec + $min * 60 + $HOUR * 3600 + $day * 86400
    $end = _DateAdd('s', $Sekunden, _NowCalc())
    Local $message
    Do
    Sleep(100)
    $sec = _DateDiff('s', _NowCalc(), $end)
    If Not $VISIBLEDOWN Then
    $secShow = $Sekunden - $sec
    Else
    $secShow = $sec
    EndIf
    Select
    Case $secShow < 60
    If $ALTERNATECTRL = 'TT' Then
    ToolTip(StringFormat('%02u', $secShow) & ' s')
    Else
    GUICtrlSetData($ALTERNATECTRL, StringFormat('%02u', $secShow) & ' s')
    EndIf
    Case $secShow < 60 * 60
    $message = StringFormat('%02u', Floor($secShow / 60)) & ':' & _
    StringFormat('%02u', Mod($secShow, 60)) & ' min'
    If $ALTERNATECTRL = 'TT' Then
    ToolTip($message)
    Else
    GUICtrlSetData($ALTERNATECTRL, $message)
    EndIf
    Case $secShow < 60 * 60 * 24
    $message = StringFormat('%02u', Floor($secShow / 3600)) & ':' & _
    StringFormat('%02u', Floor(Mod($secShow, 3600) / 60)) & ':' & _
    StringFormat('%02u', Mod(Mod($secShow, 3600), 60)) & ' h'
    If $ALTERNATECTRL = 'TT' Then
    ToolTip($message)
    Else
    GUICtrlSetData($ALTERNATECTRL, $message)
    EndIf
    Case Else
    $message = Floor($secShow / 86400) & ' d / ' & _
    StringFormat('%02u', Floor(Mod($secShow, 86400) / 3600)) & ':' & _
    StringFormat('%02u', Floor(Mod(Mod($secShow, 86400), 3600) / 60)) & ':' & _
    StringFormat('%02u', Mod(Mod(Mod($secShow, 86400), 3600), 60)) & ' h'
    If $ALTERNATECTRL = 'TT' Then
    ToolTip($message)
    Else
    GUICtrlSetData($ALTERNATECTRL, $message)
    EndIf
    EndSelect

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

    Until $sec = 0 Or $stopit = 1
    $stopit = 0
    #cs
    If $sec = 0 Then
    GUICtrlSetData($tLabel_timer, " It's time")
    SoundPlay(@ScriptDir & "\alarma.wav", 1)
    EndIf
    #ce
    EndFunc ;==>_CountDown

    [/autoit]