Shutdown

  • Hi Leute Ich bin neu hier im Forum unwollte mal mein erstes Programm vorstellen.Ich bin erst ganz neu in der Autoit programirung.
    Ich habe ein problem ..Wen man Button "About" Drückt Öffnet sich ein weiters fenster..Wen man dieses aber wieder schliest ..schliest sich das ganze programm..
    Frage: Wie kann ich das verhindern?
    thx schon mal im vroaus


    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1_1 = GUICreate("Shutdown", 397, 137, 256, 242)
    $Input = GUICtrlCreateInput("", 64, 16, 209, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
    $Input1 = GUICtrlCreateInput("", 64, 56, 209, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
    $Label1 = GUICtrlCreateLabel("Stunden", 8, 16, 44, 17, -1, $WS_EX_STATICEDGE)
    $Label2 = GUICtrlCreateLabel("Minuten", 8, 56, 42, 17, -1, $WS_EX_STATICEDGE)
    $Button1 = GUICtrlCreateButton("Start", 64, 88, 97, 33, BitOR($BS_DEFPUSHBUTTON,$WS_GROUP))
    $Button3 = GUICtrlCreateButton("About", 288, 88, 97, 33, BitOR($BS_DEFPUSHBUTTON,$WS_GROUP))
    $Button2 = GUICtrlCreateButton("End", 176, 88, 97, 33, BitOR($BS_DEFPUSHBUTTON,$WS_GROUP))
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $Stunden = GUICtrlRead( $Input )
    $Minuten = GUICtrlRead( $Input1 )
    sleep( $Stunden *3600000)
    Sleep( $Minuten *60000)
    Shutdown( 5 )
    Case $Button2
    Exit
    Case $Button3
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <TabConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1_1 = GUICreate("About", 276, 156, 415, 289)
    $Tab1 = GUICtrlCreateTab(0, 0, 273, 153, $TCS_SCROLLOPPOSITE)
    GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
    $TabSheet1 = GUICtrlCreateTabItem("Macher")
    $Label1 = GUICtrlCreateLabel("Vorname: Jannis", 8, 32, 109, 19)
    GUICtrlSetFont(-1, 9, 400, 0, "Arial")
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    $Label2 = GUICtrlCreateLabel("Nachname: Gatzenberger", 8, 56, 148, 19)
    GUICtrlSetFont(-1, 9, 400, 0, "Arial")
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    $TabSheet2 = GUICtrlCreateTabItem("Kontakt")
    $Label3 = GUICtrlCreateLabel("Email: JannisGatzenberger@gmx.de", 10, 31, 232, 19)
    GUICtrlSetFont(-1, 9, 400, 0, "Arial")
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    $Label4 = GUICtrlCreateLabel("Homepage: Jannis-hat-keine-homepage.de", 8, 56, 245, 19)
    GUICtrlSetFont(-1, 9, 400, 0, "Arial")
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlCreateTabItem("")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    EndSwitch
    WEnd

    [/autoit]
  • So?

    Spoiler anzeigen
    [autoit]

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

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

    Opt("GUIOnEventMode", 1) ;Aktiviert den GUIOnEventMode

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

    #region ### START Koda GUI section ###
    $MainGUI = GUICreate("Shutdown", 397, 137, 256, 242)
    GUISetOnEvent(-3, "_Exit") ;Wenn das "x" des Fensters gedrückt wurde, dann soll er die Funktion "_Exit" ausführen
    $Input = GUICtrlCreateInput("", 64, 16, 209, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
    $Input1 = GUICtrlCreateInput("", 64, 56, 209, 21, BitOR($ES_AUTOHSCROLL, $ES_NUMBER))
    $Label1 = GUICtrlCreateLabel("Stunden", 8, 16, 44, 17, -1, $WS_EX_STATICEDGE)
    $Label2 = GUICtrlCreateLabel("Minuten", 8, 56, 42, 17, -1, $WS_EX_STATICEDGE)
    $Button1 = GUICtrlCreateButton("Start", 64, 88, 97, 33, BitOR($BS_DEFPUSHBUTTON, $WS_GROUP))
    GUICtrlSetOnEvent(-1, "_Shutdown") ;Wenn der Button "Start" gedrückt wurde, dann soll er die Funktion "_Shutdown" ausführen
    $Button3 = GUICtrlCreateButton("About", 288, 88, 97, 33, BitOR($BS_DEFPUSHBUTTON, $WS_GROUP))
    GUICtrlSetOnEvent(-1, "_About") ;Wenn der Button "About" gedrückt wurde, dann soll er die Funktion "_About" ausführen
    $Button2 = GUICtrlCreateButton("End", 176, 88, 97, 33, BitOR($BS_DEFPUSHBUTTON, $WS_GROUP))
    GUICtrlSetOnEvent(-1, "_Exit") ;Wenn der Button "End" gedrückt wurde, dann soll er die Funktion "_Exit" ausführen
    GUISetState(@SW_SHOW) ;Das Fenster wird sichtbar aufgerufen
    #endregion ### END Koda GUI section ###

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

    #region ### START Koda GUI section ###
    $AboutGUI = GUICreate("About", 276, 156, 415, 289)
    GUISetOnEvent(-3, "_Change") ;Wenn das "x" des Fensters gedrückt wurde, dann soll er die Funktion "_Change" ausführen
    $Tab1 = GUICtrlCreateTab(0, 0, 273, 153, $TCS_SCROLLOPPOSITE)
    GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
    $TabSheet1 = GUICtrlCreateTabItem("Macher")
    $Label1 = GUICtrlCreateLabel("Vorname: Jannis", 8, 32, 109, 19)
    GUICtrlSetFont(-1, 9, 400, 0, "Arial")
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    $Label2 = GUICtrlCreateLabel("Nachname: Gatzenberger", 8, 56, 148, 19)
    GUICtrlSetFont(-1, 9, 400, 0, "Arial")
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    $TabSheet2 = GUICtrlCreateTabItem("Kontakt")
    $Label3 = GUICtrlCreateLabel("Email: JannisGatzenberger@gmx.de", 10, 31, 232, 19)
    GUICtrlSetFont(-1, 9, 400, 0, "Arial")
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    $Label4 = GUICtrlCreateLabel("Homepage: Jannis-hat-keine-homepage.de", 8, 56, 245, 19)
    GUICtrlSetFont(-1, 9, 400, 0, "Arial")
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlCreateTabItem("")
    GUISetState(@SW_HIDE) ;Das Fenster wird unsichtbar augerufen
    #endregion ### END Koda GUI section ###

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

    While 1 ;Endlosschleife
    Sleep(50)
    WEnd

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

    Func _Exit()
    Exit ; Beendet das Script
    EndFunc ;==>_Exit

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

    Func _Change()
    GUISetState(@SW_HIDE, $AboutGUI) ;Versteckt das Fenster "AboutGUI"
    Sleep(100)
    GUISetState(@SW_SHOW, $MainGUI) ;Zeigt das Fenster "MainGUI"
    EndFunc ;==>_Change

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

    Func _About()
    GUISetState(@SW_SHOW, $AboutGUI) ;Zeigt das Fenster "AboutGUI"
    Sleep(100)
    GUISetState(@SW_HIDE, $MainGUI) ;Versteckt das Fenster "MainGUI"
    EndFunc ;==>_About

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

    Func _Shutdown()
    $Stunden = GUICtrlRead($Input)
    $Minuten = GUICtrlRead($Input1)
    Sleep($Stunden * 3600000)
    Sleep($Minuten * 60000)
    Shutdown(5)
    EndFunc ;==>_Shutdown

    [/autoit]

    Und bitte, lies dir den OnEventMode in der Hilfe durch, der hilft ;)
    Aber auch die Kommentare!

  • Das geht nimm es
    Quelle : Forum

    Spoiler anzeigen
    [autoit]

    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_icon=..\..\..\Icons\sd.ico
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include <Array.au3>
    #include <Date.au3>
    #include <WinAPI.au3>
    #include <Constants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <ButtonConstants.au3>
    #Include <Misc.au3>

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

    If _Singleton(@ScriptName, 1) = 0 Then Exit Msgbox(16,"Warning","An occurence is already running", 10)

    $ini = @ScriptDir & "\SD_Settings.ini"

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

    Global $handle, $NoTray, $Hide, $Trans, $Corner, $Resist, $Top, $T3, $T4, $T5, $T2_1, $T2_2, $T2_3, $T2_4, $T1_1, $T1_2, $T1_3, $T1_4, $T1_5, $T1_6, $T1_7, $T1_8, $T1_9, $T1_10, $T1_11, $H, $M, $S
    Global $bHook = 1, $head, $sec, $end, $secShow

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

    Opt("TrayOnEventMode", 1)
    Opt("TrayAutoPause",0)
    Opt("TrayMenuMode",1)

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

    $NoTray = IniRead($ini, "Settings", "No_Tray", "0")
    $Corner = IniRead($ini, "Settings", "Corner", "1")
    $Hide = IniRead($ini, "Settings", "Hide_Window", "0")
    $Trans = IniRead($ini, "Settings", "Transparence", "10")
    $Top = IniRead($ini, "Settings", "On_Top", "1")
    $Resist = IniRead($ini, "Settings", "Resisstant", "1")

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

    If $CmdLine[0] = 0 Then
    #Region ### START Koda GUI section ### Form=
    $Form1_1 = GUICreate("")
    $Group1 = GUICtrlCreateGroup("Methode", 0, 0, 209, 41)
    $Radio1 = GUICtrlCreateRadio("Shutdown", 11, 16, 73, 17)
    GUICtrlSetState(-1, 1)
    $Radio2 = GUICtrlCreateRadio("Neustart", 85, 16, 57, 17)
    $Radio3 = GUICtrlCreateRadio("Abmelden", 146, 16, 57, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group2 = GUICtrlCreateGroup("Uhrzeit", 0, 42, 209, 89)
    $Radio4 = GUICtrlCreateRadio("Stunden", 8, 58, 65, 17)
    $Radio5 = GUICtrlCreateRadio("Minuten", 8, 74, 65, 17)
    GUICtrlSetState(-1, 1)
    $Radio6 = GUICtrlCreateRadio("Sekunden", 8, 90, 65, 17)
    $Radio7 = GUICtrlCreateRadio("Zeit", 8, 106, 65, 17)
    $Input1 = GUICtrlCreateInput("", 79, 76, 81, 21)
    $Button1 = GUICtrlCreateButton(">", 195, 56, 9, 49, 0)
    GUICtrlSetTip(-1, "Shows advanced Settings")
    $Button2 = GUICtrlCreateButton("OK", 165, 111, 41, 17, $BS_DEFPUSHBUTTON )
    GUICtrlSetState($Input1, $GUI_FOCUS)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
    $Form2 = GUICreate("Einstellung")
    $Checkbox1 = GUICtrlCreateCheckbox("Kein Icon", 2, 3, 89, 17)
    If $NoTray = 1 Then GUICtrlSetState(-1, 1)
    $Checkbox2 = GUICtrlCreateCheckbox("Minimieren", 2, 20, 89, 17)
    If $Hide = 1 Then GUICtrlSetState(-1, 1)
    $Checkbox3 = GUICtrlCreateCheckbox("Vordergrund", 2, 37, 89, 17)
    If $Top = 1 Then GUICtrlSetState(-1, 1)
    $Checkbox4 = GUICtrlCreateCheckbox("Resisstant", 2, 53, 89, 17)
    If $Resist = 1 Then GUICtrlSetState(-1, 1)
    $Label1 = GUICtrlCreateLabel("Position", 0, 80, 67, 17)
    $Label2 = GUICtrlCreateLabel("Transparence", 0, 107, 70, 17)
    $Combo1 = GUICtrlCreateCombo("", 72, 77, 97, 25)
    Select
    Case $Corner = 1
    GUICtrlSetData(-1, "Oben Links|Oben Rechts|Unten Rechts|Unten Links|Vollbild", "Oben Links")
    Case $Corner = 2
    GUICtrlSetData(-1, "Oben Links|Oben Rechts|Unten Rechts|Unten Links|Vollbild", "Oben Rechts")
    Case $Corner = 3
    GUICtrlSetData(-1, "Oben Links|Oben Rechts|Unten Rechts|Unten Links|Vollbild", "Unten Rechts")
    Case $Corner = 4
    GUICtrlSetData(-1, "Oben Links|Oben Rechts|Unten Rechts|Unten Links|Vollbild", "Unten Links")
    Case $Corner = 5
    GUICtrlSetData(-1, "Oben Links|Oben Rechts|Unten Rechts|Unten Links|Vollbild", "Unten Links")
    Case Else
    GUICtrlSetData(-1, "Oben Links|Oben Rechts|Unten Rechts|Unten Links|Vollbild", "Vollbild")
    EndSelect
    $Combo2 = GUICtrlCreateCombo("", 72, 104, 65, 25)
    GUICtrlSetData(-1, "0|10|20|30|40|50|60|70|80|90|100", $Trans)
    $Label3 = GUICtrlCreateLabel("%", 148, 108, 12, 17)
    GUISetState(@SW_SHOW, $Form1_1)
    #EndRegion ### END Koda GUI section ###

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

    #

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

    $GUIPos = WinGetPos($Form1_1)

    GUIRegisterMsg($WM_MOVE, "_MoveUrAss")

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $WGS = WinGetState($Form2)
    If $WGS = 5 Then
    GUISetState(@SW_SHOW, $Form2)
    Else
    GUISetState(@SW_HIDE, $Form2)
    EndIf
    Case $Button2
    $ValueI1 = GUICtrlRead($Input1)
    If $ValueI1 = "" Then
    MsgBox(16, "Error", "You have to enter some Numbers")
    ContinueLoop
    EndIf
    $ValueR1 = GUICtrlRead($Radio1)
    $ValueR2 = GUICtrlRead($Radio2)
    $ValueR3 = GUICtrlRead($Radio3)
    $ValueR4 = GUICtrlRead($Radio4)
    $ValueR5 = GUICtrlRead($Radio5)
    $ValueR6 = GUICtrlRead($Radio6)
    $ValueR7 = GUICtrlRead($Radio7)
    If $ValueR1 = 1 Then
    $Par1 = " -s "
    ElseIf $ValueR2 = 1 Then
    $Par1 = " -r "
    ElseIf $ValueR3 = 1 Then
    $Par1 = " -l "
    EndIf
    If $ValueR4 = 1 Then
    $Par2 = "-h "
    ElseIf $ValueR5 = 1 Then
    $Par2 = "-m "
    ElseIf $ValueR6 = 1 Then
    $Par2 = "-s "
    ElseIf $ValueR7 = 1 Then
    $Par2 = "-t "
    EndIf
    $ValueCB1 = GUICtrlRead($Checkbox1)
    $ValueCB2 = GUICtrlRead($Checkbox2)
    $ValueCB3 = GUICtrlRead($Checkbox3)
    $ValueCB4 = GUICtrlRead($Checkbox4)
    $ValueC1 = GUICtrlRead($Combo1)
    $ValueC2 = GUICtrlRead($Combo2)
    $Par3 = " "
    If $ValueCB1 = 1 Then $Par3 = $Par3 & "-notray "
    If $ValueCB2 = 1 Then $Par3 = $Par3 & "-hide "
    If $ValueCB3 = 0 Then $Par3 = $Par3 & "-notop "
    If $ValueCB4 = 0 Then $Par3 = $Par3 & "-noresist "
    If $ValueC2 <> "" Then $Par3 = $Par3 & "-trans " & $ValueC2 & " "
    If $ValueC1 <> "" Then
    Select
    Case $ValueC1 = "Left Top"
    $Par3 = $Par3 & "-corner 1"
    Case $ValueC1 = "Right Top"
    $Par3 = $Par3 & "-corner 2"
    Case $ValueC1 = "Right Bottom"
    $Par3 = $Par3 & "-corner 3"
    Case $ValueC1 = "Left Bottom"
    $Par3 = $Par3 & "-corner 4"
    Case $ValueC1 = "Full Screen"
    $Par3 = $Par3 & "-corner 5"
    Case Else
    $Par3 = $Par3 & "-corner 1"
    EndSelect
    EndIf
    ShellExecute(@AutoItExe, $Par1 & $Par2 & $ValueI1 & $Par3, @ScriptDir)
    Exit
    EndSwitch
    WEnd
    EndIf

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

    HotKeySet("!{END}", "_ToogleTray") ;show/hide Tray
    HotKeySet("{End}", "_kill")
    Global $Paused
    HotKeySet("{PAUSE}", "TogglePause")

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

    TraySetToolTip("ShutDown by sc4ry")

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

    _createTray()

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

    If $CmdLine[0] >= 3 Then
    If $CmdLine[1] = "-l" Or $CmdLine[1] = "-s" Or $CmdLine[1] = "-r" Then
    $Funktion = $CmdLine[1]
    If $CmdLine[2] = "-t" Or $CmdLine[2] = "-h" Or $CmdLine[2] = "-m" Or $CmdLine[2] = "-s" Then
    $TimeZone = $CmdLine[2]
    If StringRegExp($CmdLine[3], "[0-9]+") Then
    $Countdown = $CmdLine[3]
    If _ArraySearch($CmdLine, "-notray") <> -1 Then $NoTray = 1
    If _ArraySearch($CmdLine, "-hide") <> -1 Then $Hide = 1
    If _ArraySearch($CmdLine, "-notop") <> -1 Then $Top = 0
    If _ArraySearch($CmdLine, "-noresist") <> -1 Then $Resist = 0
    $vValue = _ArraySearch($CmdLine, "-corner")
    If $vValue <> -1 Then $Corner = $CmdLine[$vValue + 1]
    If $Corner < 1 Then
    $Corner = 1
    ElseIf $Corner > 5 Then
    $Corner = 4
    EndIf
    $vValue = _ArraySearch($CmdLine, "-trans")
    If $vValue <> -1 Then $Trans = $CmdLine[$vValue + 1]
    If $Trans < 0 Then
    $Trans = 0
    ElseIf $Trans > 100 Then
    $Trans = 100
    EndIf
    _countDown($Countdown)
    Else
    _Help()
    EndIf
    Else
    _Help()
    EndIf
    Else
    _Help()
    EndIf
    Else
    _Help()
    EndIf

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

    Func _MoveUrAss()
    $GuiPosExt = WinGetPos($Form1_1)
    If Not $GuiPosExt[0] <> $GUIPos[0] Or $GuiPosExt[1] <> $GUIPos[1] Then
    WinMove($Form2, "", $GuiPosExt[0] + 217, $GuiPosExt[1])
    EndIf
    EndFunc ;==>_MoveUrAss

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

    ;countdown Function
    Func _countDown($Countdown)
    ;action?
    If $CmdLine[1] = "-l" Then
    $head = "Logoff"
    ElseIf $CmdLine[1] = "-s" Then
    $head = "Shutdown"
    ElseIf $CmdLine[1] = "-r" Then
    $head = "Reboot"
    EndIf

    ;countdowns
    If $CmdLine[2] = "-s" Then
    $ttt = _TimeToTicks(@HOUR, @MIN)
    $ttt2 = _TimeToTicks(0, 0, $Countdown)
    _TicksToTime($ttt + $ttt2, $H, $M, $S)
    If StringLen($H) = 1 Then $H = 0 & $H
    If $H >= 24 Then
    Do
    $H = $H - 24
    Until $H <= 24
    If StringLen($H) = 1 Then $H = 0 & $H
    EndIf
    If StringLen($M) = 1 Then $M = 0 & $M
    If StringLen($S) = 1 Then $S = 0 & $S
    $handle = SplashTextOn($head, "", 130, 50, 1, 1, 1, "", 10, 400)
    _Do_Settings()
    _FinalCountDown($Countdown, 0, 0, 0, True)
    EndIf

    If $CmdLine[2] = "-m" Then
    $ttt = _TimeToTicks(@HOUR, @MIN)
    $ttt2 = _TimeToTicks(0, $Countdown)
    _TicksToTime($ttt + $ttt2, $H, $M, $S)
    If StringLen($H) = 1 Then $H = 0 & $H
    If $H >= 24 Then
    Do
    $H = $H - 24
    Until $H <= 24
    If StringLen($H) = 1 Then $H = 0 & $H
    EndIf
    If StringLen($M) = 1 Then $M = 0 & $M
    If StringLen($S) = 1 Then $S = 0 & $S
    $handle = SplashTextOn($head, "", 130, 50, 1, 1, 1, "", 10, 400)
    _Do_Settings()
    _FinalCountDown(0, $Countdown, 0, 0, True)
    EndIf

    If $CmdLine[2] = "-h" Then
    $ttt = _TimeToTicks(@HOUR, @MIN)
    $ttt2 = _TimeToTicks(0, $Countdown * 60)
    _TicksToTime($ttt + $ttt2, $H, $M, $S)
    If StringLen($H) = 1 Then $H = 0 & $H
    If $H >= 24 Then
    Do
    $H = $H - 24
    Until $H <= 24
    If StringLen($H) = 1 Then $H = 0 & $H
    EndIf
    If StringLen($M) = 1 Then $M = 0 & $M
    If StringLen($S) = 1 Then $S = 0 & $S
    $handle = SplashTextOn($head, "", 130, 50, 1, 1, 1, "", 10, 400)
    _Do_Settings()
    _FinalCountDown(0, 0, $Countdown, 0, True)
    EndIf

    If $CmdLine[2] = "-t" Then
    $ShutDownTime = $CmdLine[3]
    If $ShutDownTime < @HOUR & ':' & @MIN Then
    $now = @YEAR & '/' & @MON & '/' & @MDAY+1
    Else
    $now = @YEAR & '/' & @MON & '/' & @MDAY
    EndIf
    $string = StringSplit($ShutDownTime, ":")
    If Not @error Then
    $H = $string[1]
    $M = $string[2]
    Else
    Exit MsgBox(16, "Error", "Wrong Format")
    EndIf
    $min = _DateDiff('n', _NowCalc(), $now & ' ' & $ShutDownTime )
    $Countdown = $min + 1
    $handle = SplashTextOn($head, "", 130, 50, 1, 1, 1, "", 10, 400)
    _Do_Settings()
    _FinalCountDown(0, $Countdown, 0, 0, True)
    EndIf

    ;action
    If $CmdLine[1] = "-l" Then
    ;~ Shutdown(4) ; Logoff und Force
    SplashTextOn("", $head, 150, 30, -1, -1, 1 + 32, "", "", 1000)
    While 1
    Sleep(1)
    WEnd
    ElseIf $CmdLine[1] = "-s" Then
    ;~ Shutdown(13) ; Shutdown, Powerdown und Force
    SplashTextOn("", $head, 150, 30, -1, -1, 1 + 32, "", "", 1000)
    While 1
    Sleep(1)
    WEnd
    ElseIf $CmdLine[1] = "-r" Then
    ;~ Shutdown(6) ; Reboot und Force
    SplashTextOn("", $head, 150, 30, -1, -1, 1 + 32, "", "", 1000)
    While 1
    Sleep(1)
    WEnd
    EndIf
    EndFunc ;==>_countDown

    Func _FinalCountDown($SEC, $MIN=0, $HOUR=0, $DAY=0, $VISIBLEDOWN=True)
    $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
    ControlSetText($handle, "", "[CLASS:Static; INSTANCE:1]", $head & @CRLF & "at: " & $H & ":" & $M & @CRLF & "in: " & StringFormat('%02u', $secShow) & ' s')
    Case $secShow < 60*60
    $message = StringFormat('%02u', Floor($secShow/60)) & ':' & _
    StringFormat('%02u', Mod($secShow,60)) & ' min'
    ControlSetText($handle, "", "[CLASS:Static; INSTANCE:1]", $head & @CRLF & "at: " & $H & ":" & $M & @CRLF & "in: " & $message)
    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'
    ControlSetText($handle, "", "[CLASS:Static; INSTANCE:1]", $head & @CRLF & "at: " & $H & ":" & $M & @CRLF & "in: " & $message)
    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'
    ControlSetText($handle, "", "[CLASS:Static; INSTANCE:1]", $head & @CRLF & "at: " & $H & ":" & $M & @CRLF & "in: " & $message)
    EndSelect
    $pos = WinGetPos($handle)
    ;~ Exit MsgBox(0, _WinIsOnTop($handle), $pos[2] & @TAB & @DesktopWidth - 2 & @CRLF & $pos[3] & @TAB & @DesktopHeight - 2)
    If $pos[2] = @DesktopWidth - 2 And $pos[3] = @DesktopHeight - 2 And _WinIsOnTop($handle) Then WinSetOnTop($handle, "", 1)
    Until $sec = 0
    EndFunc ;==>_CountDown by BugFix ([email='bugfix@autoit.de'][/email])

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

    Func _createTray()
    $T1 = TrayCreateMenu("Transparence")
    $T1_1 = TrayCreateItem("0 %", $T1, -1, 1)
    TrayItemSetOnEvent(-1, "_Trans")
    $T1_2 = TrayCreateItem("10 %", $T1, -1, 1)
    TrayItemSetOnEvent(-1, "_Trans")
    $T1_3 = TrayCreateItem("20 %", $T1, -1, 1)
    TrayItemSetOnEvent(-1, "_Trans")
    $T1_4 = TrayCreateItem("30 %", $T1, -1, 1)
    TrayItemSetOnEvent(-1, "_Trans")
    $T1_5 = TrayCreateItem("40 %", $T1, -1, 1)
    TrayItemSetOnEvent(-1, "_Trans")
    $T1_6 = TrayCreateItem("50 %", $T1, -1, 1)
    TrayItemSetOnEvent(-1, "_Trans")
    $T1_7 = TrayCreateItem("60 %", $T1, -1, 1)
    TrayItemSetOnEvent(-1, "_Trans")
    $T1_8 = TrayCreateItem("70 %", $T1, -1, 1)
    TrayItemSetOnEvent(-1, "_Trans")
    $T1_9 = TrayCreateItem("80 %", $T1, -1, 1)
    TrayItemSetOnEvent(-1, "_Trans")
    $T1_10 = TrayCreateItem("90 %", $T1, -1, 1)
    TrayItemSetOnEvent(-1, "_Trans")
    $T1_11 = TrayCreateItem("100 %", $T1, -1, 1)
    TrayItemSetOnEvent(-1, "_Trans")
    $T2 = TrayCreateMenu("Corner")
    $T2_1 = TrayCreateItem("Top Left", $T2, -1, 1)
    TrayItemSetOnEvent(-1, "_Corner")
    $T2_2 = TrayCreateItem("Top Right", $T2, -1, 1)
    TrayItemSetOnEvent(-1, "_Corner")
    $T2_3 = TrayCreateItem("Bottem Right", $T2, -1, 1)
    TrayItemSetOnEvent(-1, "_Corner")
    $T2_4 = TrayCreateItem("Bottom Left", $T2, -1, 1)
    TrayItemSetOnEvent(-1, "_Corner")
    $T2_5 = TrayCreateItem("Full Screen", $T2)
    TrayItemSetOnEvent(-1, "_Corner")
    TrayCreateItem("")
    $T3 = TrayCreateItem("Resisstant")
    TrayItemSetOnEvent(-1, "_Resist")
    $T4 = TrayCreateItem("On Top")
    TrayItemSetState(-1, 1)
    TrayItemSetOnEvent(-1, "_Top")
    ;~ $T5 = TrayCreateItem("Pause")
    ;~ TrayItemSetOnEvent(-1, "TogglePause")
    TrayCreateItem("")
    $T6 = TrayCreateItem("Exit")
    TrayItemSetOnEvent(-1, "_kill")
    EndFunc

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

    Func _kill()
    Exit
    EndFunc ;==>_kill

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

    Func _Do_Settings()
    If $NoTray = "1" Then Opt("TrayIconHide", 1)
    If $Hide = 1 Then WinSetState($handle, "", @SW_HIDE)
    WinSetTrans($handle, "", (100 - $Trans) * 255 / 100)
    ;~ If Not $TransValue = 0 Or $TransValue = 10 Or $TransValue = 20 Or $TransValue = 30 Or $TransValue = 40 Or $TransValue = 50 Or $TransValue = 60 Or $TransValue = 70 Or $TransValue = 80 Or $TransValue = 90 Or $TransValue = 100 Then $TransValue = Round($TransValue, -1)
    If $Trans <> 0 And $Trans <> 10 And $Trans <> 20 And $Trans <> 30 And $Trans <> 40 And $Trans <> 50 And $Trans <> 60 And $Trans <> 70 And $Trans <> 80 And $Trans <> 90 And $Trans <> 100 Then $Trans = Round($Trans, -1)
    Select
    Case $Trans = "0"
    TrayItemSetState($T1_1, 1)
    Case $Trans = "10"
    TrayItemSetState($T1_2, 1)
    Case $Trans = "20"
    TrayItemSetState($T1_3, 1)
    Case $Trans = "30"
    TrayItemSetState($T1_4, 1)
    Case $Trans = "40"
    TrayItemSetState($T1_5, 1)
    Case $Trans = "50"
    TrayItemSetState($T1_6, 1)
    Case $Trans = "60"
    TrayItemSetState($T1_7, 1)
    Case $Trans = "70"
    TrayItemSetState($T1_8, 1)
    Case $Trans = "80"
    TrayItemSetState($T1_9, 1)
    Case $Trans = "90"
    TrayItemSetState($T1_10, 1)
    Case $Trans = "100"
    TrayItemSetState($T1_11, 1)
    EndSelect
    If $Resist = 1 Then
    _Win_SetClickThrough($handle, "", True)
    TrayItemSetState($T3, 1)
    EndIf
    If $Top = 0 Then
    WinSetOnTop($handle, "", 0)
    TrayItemSetState($T4, 4)
    EndIf
    Select
    Case $Corner = 1
    $x = 1
    $y = 1
    TrayItemSetState($T2_1, 1)
    Case $Corner = 2
    $x = @DesktopWidth - 132
    $y = 1
    TrayItemSetState($T2_2, 1)
    Case $Corner = 3
    $x = @DesktopWidth - 132
    $y = @DesktopHeight - 80
    TrayItemSetState($T2_3, 1)
    Case $Corner = 4
    $x = 1
    $y = @DesktopHeight - 80
    TrayItemSetState($T2_4, 1)
    Case $Corner = 5
    $x = 1
    $y = 1
    Case Else
    $x = 1
    $y = 1
    TrayItemSetState($T2_1, 1)
    EndSelect
    If $Corner = 5 Then
    WinMove($handle, "", $x, $y, @DesktopWidth - 2, @DesktopHeight - 2)
    Else
    WinMove($handle, "", $x, $y, 130, 50)
    EndIf
    EndFunc

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

    Func _Help()
    If Not _WinAPI_AttachConsole() Then
    $ret = DllCall("Kernel32.dll", "long", "AllocConsole")
    If $ret = 0 Then Exit
    EndIf
    $hConsole = _WinAPI_GetStdHandle(1)
    $hConsoleIn = _WinAPI_GetStdHandle(0)
    If $hConsole = -1 Then Exit
    _WinAPI_WriteConsole($hConsole, @CRLF & @CRLF & 'Possible Commands are...' & @CRLF & @CRLF & 'Parameter 1:' & @CRLF & '-l = Logoff' & @CRLF & '-r = Reboot' & @CRLF & '-s = Shutdown' & @CRLF & @CRLF & 'Parameter 2:' & @CRLF & '-s = Seconds' & @CRLF & '-m = Minutes' & @CRLF & '-h = Hours' & @CRLF & '-t = Time' & @CRLF & @CRLF & 'Parameter 3:' & @CRLF & '0 - 9' & @CRLF & @CRLF & 'Example: ' & @ScriptName & ' -s -m 10' & @CRLF & @CRLF & 'This will shutdown your PC in 10 Minutes'& @CRLF & @CRLF & 'Press ENTER to Continue' & @CRLF & @CRLF)
    Exit
    EndFunc

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

    Func _Resist()
    $Style = _WinAPI_GetWindowLong($handle,$GWL_EXSTYLE)
    If BitAND($Style,$WS_EX_TRANSPARENT) = $WS_EX_TRANSPARENT And BitAND($Style,$WS_EX_LAYERED) = $WS_EX_LAYERED Then
    _Win_SetClickThrough($handle, "", False)
    Else
    _Win_SetClickThrough($handle, "", True)
    EndIf
    EndFunc

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

    Func _Top()
    WinSetOnTop($handle, "", Not _WinIsOnTop($handle))
    EndFunc

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

    Func _Corner()
    Select
    Case @TRAY_ID = 20
    $x = 1
    $y = 1
    TrayItemSetState($T2_1, 1)
    Case @TRAY_ID = 21
    $x = @DesktopWidth - 132
    $y = 1
    TrayItemSetState($T2_2, 1)
    Case @TRAY_ID = 22
    $x = @DesktopWidth - 132
    $y = @DesktopHeight - 105
    TrayItemSetState($T2_3, 1)
    Case @TRAY_ID = 23
    $x = 1
    $y = @DesktopHeight - 105
    TrayItemSetState($T2_4, 1)
    Case @TRAY_ID = 24
    $x = 1
    $y = 1
    EndSelect
    If @TRAY_ID = 24 Then
    WinMove($handle, "", $x, $y, @DesktopWidth - 2, @DesktopHeight - 2)
    Else
    WinMove($handle, "", $x, $y, 130, 50)
    EndIf
    EndFunc

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

    func _Trans()
    Select
    Case @TRAY_ID = 8
    WinSetTrans($handle, "", 255)
    TrayItemSetState($T1_1, 1)
    Case @TRAY_ID = 9
    WinSetTrans($handle, "", 90 * 255 / 100)
    TrayItemSetState($T1_2, 1)
    Case @TRAY_ID = 10
    WinSetTrans($handle, "", 80 * 255 / 100)
    TrayItemSetState($T1_3, 1)
    Case @TRAY_ID = 11
    WinSetTrans($handle, "", 70 * 255 / 100)
    TrayItemSetState($T1_4, 1)
    Case @TRAY_ID = 12
    WinSetTrans($handle, "", 60 * 255 / 100)
    TrayItemSetState($T1_5, 1)
    Case @TRAY_ID = 13
    WinSetTrans($handle, "", 50 * 255 / 100)
    TrayItemSetState($T1_6, 1)
    Case @TRAY_ID = 14
    WinSetTrans($handle, "", 40 * 255 / 100)
    TrayItemSetState($T1_7, 1)
    Case @TRAY_ID = 15
    WinSetTrans($handle, "", 30 * 255 / 100)
    TrayItemSetState($T1_8, 1)
    Case @TRAY_ID = 16
    WinSetTrans($handle, "", 20 * 255 / 100)
    TrayItemSetState($T1_9, 1)
    Case @TRAY_ID = 17
    WinSetTrans($handle, "", 10 * 255 / 100)
    TrayItemSetState($T1_10, 1)
    Case @TRAY_ID = 18
    WinSetTrans($handle, "", 0)
    TrayItemSetState($T1_11, 1)
    EndSelect
    EndFunc

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

    Func _WinIsOnTop($WindowHandle)
    Local $long = _WinAPI_GetWindowLong(WinGetHandle($WindowHandle),$GWL_EXSTYLE)
    Return BitAND($long,8)=8 ; $WS_EX_TOPMOST = 8
    EndFunc ; Author(s): Prog@ndy

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

    Func _Win_SetClickThrough($title,$text = "",$noclic = True)
    Local $hWnd = WinGetHandle($title,$text)
    If @error Then Return SetError(1,0,0)
    If $noclic Then
    _WinAPI_SetWindowLong($hWnd,$GWL_EXSTYLE,BitOR(_WinAPI_GetWindowLong($hWnd,$GWL_EXSTYLE),$WS_EX_TRANSPARENT))
    If @error Then Return SetError(2,0,0)
    Else
    _WinAPI_SetWindowLong($hWnd,$GWL_EXSTYLE,BitAND(_WinAPI_GetWindowLong($hWnd,$GWL_EXSTYLE),BitNOT($WS_EX_TRANSPARENT)))
    If @error Then Return SetError(2,0,0)
    EndIf
    Return 1
    EndFunc ; Author(s): Prog@ndy

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

    Func _ToogleTray()
    Opt("TrayIconHide", Not Opt("TrayIconHide", "Default"))
    EndFunc

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

    Func TogglePause()
    $Paused = Not $Paused
    $time = 0
    While $Paused
    ControlSetText($handle, "", "[CLASS:Static; INSTANCE:1]", @CRLF & 'Script is "Paused"')
    Sleep(1000)
    $time += 1
    $end = _DateAdd('s', 1, $end)
    WEnd
    $ttt = _TimeToTicks($H, $M)
    $ttt2 = _TimeToTicks(0, 0, $time)
    _TicksToTime($ttt + $ttt2, $H, $M, $S)
    EndFunc ;==>TogglePause

    [/autoit]