


;GUICtrlSetData($progressbar1, (Int(TimerDiff($begin)/1000)/$time)*100)
;coded by UEZ 2011 und Progressbar eingebaut von Tuxedo
;Einsatz von_ProgressEx.au3 deshalb weil mich der blinkende Progress-Style von Win 7 stört

#AutoIt3Wrapper_UseX64=N
#AutoIt3Wrapper_Icon=prog.ico

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#include "_ProgressEx.au3"; von Oscar
Global Const $iRed = 0, $iYellow = 60, $iGreen = 120, $iBlue = -150 , $iLGreen = 75; Farbwerte/HUE gegenueber dem roten Standardwert (Werte von -180 bis +180 sind moeglich)

TraySetIcon("prog.ico")





Global Const $hGUI = GUICreate("Simple Countdown by UEZ 2011", 833, 202)
GUISetBkColor(0xBFCDDB)
GUISetIcon ("prog.ico")
Global Const $FontQual = 4
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", $FontQual)
Global Const $idUpdownStd = GUICtrlCreateUpdown($idInputStd)
GUICtrlSetLimit(-1, 999, 0)
Global Const $idLableDP1 = GUICtrlCreateLabel(":", 226, 0, 41, 155)
GUICtrlSetFont(-1, 100, 400, 0, "Times New Roman", $FontQual)
Global Const $idInputMin = GUICtrlCreateInput("3", 277, 8, 153, 159, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER))
GUICtrlSetFont(-1, 100, 400, 0, "Times New Roman", $FontQual)
Global Const $idUpdownMin = GUICtrlCreateUpdown($idInputMin)
GUICtrlSetLimit(-1, 59, 0)
Global Const $idLableDP2 = GUICtrlCreateLabel(":", 440, 0, 41, 155)
GUICtrlSetFont(-1, 100, 400, 0, "Times New Roman", $FontQual)
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", $FontQual)
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", $FontQual)
Global Const $idButtonStop = GUICtrlCreateButton("Stop", 672, 136, 147, 33)
GUICtrlSetFont(-1, 16, 400, 0, "Times New Roman")

;Global $aProgress = _ProgressEx_Create(12, 179, 800, 10, $PE_NOTEXT)
;Global $aProgress = _ProgressEx_Create(8, 179, 800, 20, $PE_NOTEXT)
Global $aProgress = _ProgressEx_Create(8, 181, 810, 10, $PE_NOTEXT)
_ProgressEx_SetData($aProgress, 100, $iGreen)

GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)
ControlFocus("", "", $idButtonStart)

Global $nMsg, $seconds


While Sleep(30)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $idButtonStart
            $seconds = GUICtrlRead($idInputStd) * 60 ^ 2 + GUICtrlRead($idInputMin) * 60 + GUICtrlRead($idInputSek) - 1
			$TotalTime = $seconds
			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

Func Countdown()
    Local $sec, $min, $hr
    $sec = Mod($seconds, 60)
    $min = Mod($seconds / 60, 60)
    $hr = Floor($seconds / 60 ^ 2)
    If GUICtrlRead($idInputStd) <> $hr Then GUICtrlSetData($idInputStd, StringFormat("%01i", $hr))
    If GUICtrlRead($idInputMin) <> $min Then GUICtrlSetData($idInputMin, StringFormat("%01i", $min))
    GUICtrlSetData($idInputSek, StringFormat("%01i", $sec))
	;_ProgressEx_SetData($aProgress, 100 / $TotalTime * $seconds, $iGreen)
	;_ProgressEx_SetData($aProgress, 100 / $TotalTime * $seconds, $iRed+(100 / $TotalTime * $seconds))
	_ProgressEx_SetData($aProgress, 100 / $TotalTime * $seconds, $seconds > 60?$iGreen:$iRed)
    If $seconds <= 0 Then
        AdlibUnRegister("Countdown")
        MsgBox(0, "Information", "Countdown reached 00:00:00")
        Exit
    EndIf
    $seconds -= 1
EndFunc   ;==>Countdown

