Multi-Timer

  • Bevorzugt ihr die OnEvent Methode, oder eher MessageLoop? 10

    1. MessageLoop (3) 30%
    2. Ich mag beides (3) 30%
    3. OnEvent (2) 20%
    4. Was ist das (2) 20%
    5. Nichts (0) 0%

    Ich habe mal eine kleinen Timer geskriptet, der es erlaubt, folgende Funktionen zeitlich zu steuern:
    -Herunterfahren
    -Abmelden
    -Strom abschalten
    -Standby
    -Ruhezustand
    -Force Down
    -Internet trennen
    -Neustart
    Eine Progressbar zeigt den jeweiligen Fortschritt an....Wenn ihr es mit Garfik mögt, zieht euch einfach die angehängte RAR.

    Spoiler anzeigen
    [autoit]

    #cs ----------------------------------------------------------------------------

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

    AutoIt Version: 3.3.0.0
    Author: Frithjof

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

    Script Function:
    Eine multifunktionaler Timer.

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

    #ce ----------------------------------------------------------------------------

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

    ; Script Start - Add your code below here

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

    ;Includes

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

    #include

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

    ;-------------------------------------------------------------------------------
    ;Globals
    Global $startbild = @ScriptDir & "\taschenuhr.jpg"

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

    ;Haupt-Gui

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

    #Region ### START Koda GUI section ### Form=d:\programme\autoit\koda\forms\multi.kxf
    $Multi = GUICreate("Multi", 629, 447, 193, 125)
    $Label1 = GUICtrlCreateLabel("Auswahl:", 24, 40, 90, 26)
    GUICtrlSetFont(-1, 14, 800, 4, "Arial")
    $Button1 = GUICtrlCreateButton("Herunterfahren", 24, 96, 89, 49, 0)
    $Button2 = GUICtrlCreateButton("Neustarten", 24, 168, 89, 49, 0)
    $Button3 = GUICtrlCreateButton("Standby", 24, 240, 89, 49, 0)
    $Button4 = GUICtrlCreateButton("Ruhezustand", 24, 312, 89, 49, 0)
    $Button5 = GUICtrlCreateButton("Internet trennen", 24, 384, 89, 49, 0)
    $Button6 = GUICtrlCreateButton("Beenden", 512, 384, 89, 49, 0)
    $Label2 = GUICtrlCreateLabel("Zeit:", 216, 40, 44, 26)
    GUICtrlSetFont(-1, 14, 800, 4, "Arial")
    $Input1 = GUICtrlCreateInput("Zeit (Min)", 272, 40, 97, 21)
    $Bild1 = GUICtrlCreatePic($startbild, 168, 90, 329, 329)
    $Button7 = GUICtrlCreateButton("Abmelden", 512, 96, 89, 49, 0)
    $Button8 = GUICtrlCreateButton("Strom abschalten", 512, 168, 89, 49, 0)
    $Button9 = GUICtrlCreateButton("Force Down", 512, 240, 89, 49, 0)
    GUISetOnEvent($GUI_EVENT_CLOSE , "Beenden")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    Opt("GUIOnEventMode", 1)
    GUICtrlSetOnEvent($Button1, "Herunterfahren")
    GUICtrlSetOnEvent($Button2, "Neustarten")
    GUICtrlSetOnEvent($Button3, "Standby")
    GUICtrlSetOnEvent($Button4, "Ruhezustand")
    GUICtrlSetOnEvent($Button5, "Internet_trennen")
    GUICtrlSetOnEvent($Button6, "Beenden")
    GUICtrlSetOnEvent($Button7, "Abmelden")
    GUICtrlSetOnEvent($Button8, "Strom_abschalten")
    GUICtrlSetOnEvent($Button9, "Force_down")

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

    Global $zahl1 ;Global, damit die Zahl in der Funktion nicht mehr geändert wird

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

    While 1
    $Zahl1 = GUICtrlRead ($Input1) ;Fragt die eingegebenen Zahlen ab, mit 1 Millisekunde Pause, um den PC nicht zu überlasten
    sleep (1)
    WEnd

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

    ;Funktionen
    Func Beenden()
    Exit
    EndFunc

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

    Func Herunterfahren()
    MsgBox(0,"Warnung", "Ihr PC wird in_" & $Zahl1 & "_Minuten Heruntergefahren")
    $Zahl_sek = $Zahl1 * 60
    ProgressOn("Fortschrittsbalken", "Fortschritt", "0 percent")
    For $i = 1 to 100 step 100 / $Zahl_sek
    sleep(1000)
    ProgressSet( $i, $i & " percent")
    Next
    ProgressSet(100 , "Fertig", "Fertig")
    sleep(500)
    ProgressOff()
    Shutdown (1)
    EndFunc

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

    Func Neustarten()
    MsgBox(0,"Warnung", "Ihr PC wird in_" & $Zahl1 & "_Minuten neu gestartet")
    $Zahl_sek = $Zahl1 * 60
    ProgressOn("Fortschrittsbalken", "Fortschritt", "0 percent")
    For $i = 1 to 100 step 100 / $Zahl_sek
    sleep(1000)
    ProgressSet( $i, $i & " percent")
    Next
    ProgressSet(100 , "Fertig", "Fertig")
    sleep(500)
    ProgressOff()
    Shutdown (2)
    EndFunc

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

    Func Standby()
    MsgBox(0,"Warnung", "Ihr PC wird in_" & $Zahl1 & "_Minuten in den Standby-Modus geschickt")
    $Zahl_sek = $Zahl1 * 60
    ProgressOn("Fortschrittsbalken", "Fortschritt", "0 percent")
    For $i = 1 to 100 step 100 / $Zahl_sek
    sleep(1000)
    ProgressSet( $i, $i & " percent")
    Next
    ProgressSet(100 , "Fertig", "Fertig")
    sleep(500)
    ProgressOff()
    Shutdown (32)
    EndFunc

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

    Func Ruhezustand()
    MsgBox(0,"Warnung", "Ihr PC wird in_" & $Zahl1 & "_Minuten in den Ruuhezustand geschickt")
    $Zahl_sek = $Zahl1 * 60
    ProgressOn("Fortschrittsbalken", "Fortschritt", "0 percent")
    For $i = 1 to 100 step 100 / $Zahl_sek
    sleep(1000)
    ProgressSet( $i, $i & " percent")
    Next
    ProgressSet(100 , "Fertig", "Fertig")
    sleep(500)
    ProgressOff()
    Shutdown (64)
    EndFunc

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

    Func Internet_trennen()
    MsgBox(0,"Warnung", "Ihre Internetverbindung wird in_" & $Zahl1 & "_Minuten getrennt")
    $Zahl_sek = $Zahl1 * 60
    ProgressOn("Fortschrittsbalken", "Fortschritt", "0 percent")
    For $i = 1 to 100 step 100 / $Zahl_sek
    sleep(1000)
    ProgressSet( $i, $i & " percent")
    Next
    ProgressSet(100 , "Fertig", "Fertig")
    sleep(500)
    ProgressOff()
    Shutdown (1)
    EndFunc

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

    Func Abmelden()
    MsgBox(0,"Warnung", "Ihr PC wird in_" & $Zahl1 & "_Minuten abgemeldet")
    $Zahl_sek = $Zahl1 * 60
    ProgressOn("Fortschrittsbalken", "Fortschritt", "0 percent")
    For $i = 1 to 100 step 100 / $Zahl_sek
    sleep(1000)
    ProgressSet( $i, $i & " percent")
    Next
    ProgressSet(100 , "Fertig", "Fertig")
    sleep(500)
    ProgressOff()

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

    Shutdown (0)
    EndFunc

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

    Func Strom_abschalten()
    MsgBox(0,"Warnung", "Ihrem PC wird in_" & $Zahl1 & "_Minuten der Strom abgedreht")
    $Zahl_sek = $Zahl1 * 60
    ProgressOn("Fortschrittsbalken", "Fortschritt", "0 percent")
    For $i = 1 to 100 step 100 / $Zahl_sek
    sleep(1000)
    ProgressSet( $i, $i & " percent")
    Next
    ProgressSet(100 , "Fertig", "Fertig")
    sleep(500)
    ProgressOff()
    Shutdown (8)
    EndFunc

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

    Func Force_down()
    MsgBox(0,"Warnung", "Ihr PC wird in_" & $Zahl1 & "_zum Herunterfahren gezwungen, auch wenn das System sich aufgehängt hat")
    $Zahl_sek = $Zahl1 * 60
    ProgressOn("Fortschrittsbalken", "Fortschritt", "0 percent")
    For $i = 1 to 100 step 100 / $Zahl_sek
    sleep(1000)
    ProgressSet( $i, $i & " percent")
    Next
    ProgressSet(100 , "Fertig", "Fertig")
    sleep(500)
    ProgressOff()
    Shutdown (17)
    EndFunc

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