

#include <AutoItConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <ColorConstants.au3>

Opt("PixelCoordMode", 2)
Opt("MouseCoordMode", 2)

Global $iSeconds = 30 * 1
Global $hGui = GUICreate('Zeitgesteuertes Ausschalten', 365,125, 192, 124,BitOR($WS_CAPTION,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS))

$Label1 = GUICtrlCreateLabel('Der PC fährt in', 20, 10, 105, 20)
GUICtrlSetFont(-1, 12, 400, 0, 'Arial')
$idTime = GUICtrlCreateLabel('', 140, 6, 70, 40)
GUICtrlSetFont(-1, 16, 700, 0, 'Arial')
$Label2 = GUICtrlCreateLabel('Minuten runter ...', 210, 10, 205, 20)
GUICtrlSetFont(-1, 12, 400, 0, 'Arial')
$ButStop = GUICtrlCreateButton(" Zeit anhalten  ",20, 35, 130)
GUICtrlSetFont(-1, 8.5, 700, 0, 'Arial')
GUICtrlSetColor(-1, $COLOR_Yellow)
GUICtrlSetBkColor(-1, $COLOR_RED)
$ButWeiter = GUICtrlCreateButton(" Zeit weiterlaufen lassen ", 20, 70, 130)
 ;$ButClose = GUICtrlCreateButton("", 190, 35, 160, 60,0x00000020)
;~ GUICtrlSetFont($ButClose, 11, 600, 0, 'Arial')
;~ GUICtrlSetBKColor($ButClose, 0x00FF00)
;GUICtrlSetColor($ButClose, 0xFFFF00)
;GUICtrlSetData($ButClose, " Programm  abbrechen und  Fenster schließen ")
;GUICtrlSetStyle($ButClose, $BS_MULTILINE)
$ButLab = GUICtrlCreateLabel("Programm"&@LF&"abbrechen und"&@LF&"Fenster schließen",190,32,160,60,0x01);0x01=$SS_CENTER
GUICtrlSetFont($ButLab, 11, 600, 0, 'Arial')
GUICtrlSetBKColor($ButLab, 0x00FF00)
GUICtrlSetColor($ButLab, 0xFF0000)

;~ GUICtrlSetColor($ButClose, -1)
;~ GUICtrlSetBKColor($ButClose, -1)
; Setzt die Hintergrundfarbe des Label-Controls.

; Setzt die Schriftbarbe


AdlibRegister('_CountDown', 1000)
_CountDown()
GUISetState(@SW_SHOW)

;GUICtrlSetStyle($ButClose, $BS_MULTILINE)



While True

    Switch GUIGetMsg()

        Case $GUI_EVENT_CLOSE
            Exit
        Case $ButStop
            AdlibUnRegister('_CountDown')
         Case $ButWeiter
            AdlibRegister('_Countdown', 1000)
		Case $ButLab
			GUICtrlSetBKColor($ButLab, 0xFFFF00)
			;GUICtrlSetData($ButLab,"     Programm     "&@LF&"  abbrechen und  "&@LF&" Fenster schließen ")
            Exit
		Case $GUI_EVENT_MOUSEMOVE
			$Pos = MouseGetPos()
			If ($Pos[0] > 190 And $Pos[0] < 190+160) And ($Pos[1] > 32 And $Pos[1] < 32+60) Then
				GUICtrlSetColor($ButLab, 0x0000FF)
				GUICtrlSetBKColor($ButLab, 0xFFFF00)
				GUICtrlSetPos($ButLab, 192,34)
			Else
				GUICtrlSetColor($ButLab, 0xFF0000)
				GUICtrlSetBKColor($ButLab, 0x00FF00)
				GUICtrlSetPos($ButLab, 190,32)
			EndIf

    EndSwitch
WEnd


Func _CountDown()
    Local $iMin, $iSec
    $iSeconds -= 1
    If $iSeconds < 0 Then
;~         Shutdown($SD_SHUTDOWN) ; Rechner herunterfahren
            MsgBox(0,"Test","JEtzt würde der PC runterfahren",10)
        Exit ; Programm beenden
    EndIf


    $iMin = Int($iSeconds / 60)
    $iSec = Mod($iSeconds, 60)
    GUICtrlSetData($idTime, StringFormat('%02i:%02i', $iMin, $iSec))
EndFunc

