Ich bin ein absoluter Anfänger und habe mr aus verschiedene Forum alles mögliche zusammengebastelt
Nun wollte ich mir ein einfaches Shutdown Programm erstellen
Doch mein Problem ist das der Countdown von der angegeben Zeit immer verschieden schnell abläuft
weil in dieser Zeitschleife noch verschiedene Abfragen enthalten sind
wenn ich denn Countdown abbrechen möchte
Hat irgendjemand eine Idee wie ich das besser realisieren könnte ?
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <GUIConstants.au3>
Opt('MustDeclareVars', 1)
[/autoit] [autoit][/autoit] [autoit]_Main()
[/autoit] [autoit][/autoit] [autoit]Func _Main()
Local $Restart, $Shutdown, $StandBy, $LogOff
Local $Label1, $Label2, $Label3
Local $Sofort, $Spaeter
Local $Minuten, $Sekunden, $Form1, $Com, $Her, $Abbrechen, $nMsg
Global $Zeit, $Main
$Main = GUICreate("EasyShutdown", 264, 250, 356, 180)
$Minuten=GUICtrlCreateInput("", 8, 200, 57, 21)
$Sekunden=GUICtrlCreateInput("", 128, 200, 57, 21)
$Restart = GUICtrlCreateButton("1", 16, 48, 40, 40, $BS_ICON)
GUICtrlSetImage(-1, "shell32.dll", 255)
$Shutdown = GUICtrlCreateButton("2", 168, 48, 40, 40, $BS_ICON)
GUICtrlSetImage(-1, "shell32.dll", 28)
$StandBy = GUICtrlCreateButton("3", 16, 112, 40, 40, $BS_ICON)
GUICtrlSetImage(-1, "shell32.dll", 26)
$LogOff = GUICtrlCreateButton("4", 168, 112, 40, 40, $BS_ICON)
GUICtrlSetImage(-1, "shell32.dll", 45)
$Label1 = GUICtrlCreateLabel("Minuten", 72, 202, 42, 17)
$Label2 = GUICtrlCreateLabel("Sekunden", 195, 202, 53, 17)
$Label3 = GUICtrlCreateLabel("Shutdown Programm by Nimmervoll Thomas", 8, 8, 214, 17)
$Sofort = GUICtrlCreateRadio("Sofort", 16, 168, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Spaeter = GUICtrlCreateRadio("Später", 130, 168, 113, 17)
GUISetState(@SW_SHOW)
GUISetState()
; Run the GUI until the dialog is closed
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $Restart
If GUICtrlRead($Sofort) = 1 Then
WinSetState($Main,"",@SW_SHOWMINNOACTIVE)
Shutdown (2)
ElseIf GUICtrlRead($Spaeter) = 1 Then
WinSetState($Main,"",@SW_SHOWMINNOACTIVE)
$Form1 = GUICreate("Form1", 230, 80, 1360, 750)
$Com = GUICtrlCreateLabel("computer wird in ", 8, 14, 84, 17)
$Her = GUICtrlCreateLabel("Label2", 92, 14, 124, 17)
$Abbrechen = GUICtrlCreateButton("Abbrechen", 88, 48, 75, 25, 0)
GUISetState(@SW_SHOW)
GUISetState()
$Zeit = (GUICtrlRead($Sekunden)*1000 + GUICtrlRead($Minuten)*60000)
while $Zeit >= 0
GUICtrlSetData($Her, Round($Zeit/1000 ,0) & "sek heruntergefahren")
Switch GUIGetMSG()
Case $GUI_EVENT_Close
ExitLoop
Case $Abbrechen
ExitLoop
EndSwitch
Sleep(90)
$Zeit = $Zeit - 100
WEnd
Switch $Zeit
Case -100
GUIDelete ($Form1)
Shutdown (2)
Case 0.1 to 99999999999
GUIDelete ($Form1)
MsgBox(1,"Info","Vorgang durch Benutzer unterbrochen")
WinSetState($Main,"",@SW_RESTORE)
EndSwitch
Else ;
EndIf
Case $Shutdown
If GUICtrlRead($Sofort) = 1 Then
WinSetState($Main,"",@SW_SHOWMINNOACTIVE)
Shutdown (1)
ElseIf GUICtrlRead($Spaeter) = 1 Then
WinSetState($Main,"",@SW_SHOWMINNOACTIVE)
$Form1 = GUICreate("Form1", 230, 80, 1360, 750)
$Com = GUICtrlCreateLabel("computer wird in ", 8, 14, 84, 17)
$Her = GUICtrlCreateLabel("Label2", 92, 14, 124, 17)
$Abbrechen = GUICtrlCreateButton("Abbrechen", 88, 48, 75, 25, 0)
GUISetState(@SW_SHOW)
GUISetState()
$Zeit = (GUICtrlRead($Sekunden)*1000 + GUICtrlRead($Minuten)*60000)
while $Zeit >= 0
GUICtrlSetData($Her, Round($Zeit/1000 ,0) & "sek heruntergefahren")
Switch GUIGetMSG()
Case $GUI_EVENT_Close
ExitLoop
Case $Abbrechen
ExitLoop
EndSwitch
Sleep(90)
$Zeit = $Zeit - 100
WEnd
Switch $Zeit
Case -100
GUIDelete ($Form1)
Shutdown (1)
Case 0.1 to 99999999999
GUIDelete ($Form1)
MsgBox(1,"Info","Vorgang durch Benutzer unterbrochen")
WinSetState($Main,"",@SW_RESTORE)
EndSwitch
Else ;
EndIf
;
Case $StandBy
If GUICtrlRead($Sofort) = 1 Then
WinSetState($Main,"",@SW_SHOWMINNOACTIVE)
Shutdown (64)
ElseIf GUICtrlRead($Spaeter) = 1 Then
WinSetState($Main,"",@SW_SHOWMINNOACTIVE)
$Form1 = GUICreate("Form1", 230, 80, 1360, 750)
$Com = GUICtrlCreateLabel("computer wird in ", 8, 14, 84, 17)
$Her = GUICtrlCreateLabel("Label2", 92, 14, 124, 17)
$Abbrechen = GUICtrlCreateButton("Abbrechen", 88, 48, 75, 25, 0)
GUISetState(@SW_SHOW)
GUISetState()
$Zeit = (GUICtrlRead($Sekunden)*1000 + GUICtrlRead($Minuten)*60000)
while $Zeit >= 0
GUICtrlSetData($Her, Round($Zeit/1000 ,0) & "sek heruntergefahren")
Switch GUIGetMSG()
Case $GUI_EVENT_Close
ExitLoop
Case $Abbrechen
ExitLoop
EndSwitch
Sleep(90)
$Zeit = $Zeit - 100
WEnd
Switch $Zeit
Case -100
GUIDelete ($Form1)
Shutdown (64)
Case 0.1 to 99999999999
GUIDelete ($Form1)
MsgBox(1,"Info","Vorgang durch Benutzer unterbrochen")
WinSetState($Main,"",@SW_RESTORE)
EndSwitch
Else ;
EndIf
Case $LogOff
If GUICtrlRead($Sofort) = 1 Then
WinSetState($Main,"",@SW_SHOWMINNOACTIVE)
Shutdown (0)
ElseIf GUICtrlRead($Spaeter) = 1 Then
WinSetState($Main,"",@SW_SHOWMINNOACTIVE)
$Form1 = GUICreate("Form1", 230, 80, 1360, 750)
$Com = GUICtrlCreateLabel("computer wird in ", 8, 14, 84, 17)
$Her = GUICtrlCreateLabel("Label2", 92, 14, 124, 17)
$Abbrechen = GUICtrlCreateButton("Abbrechen", 88, 48, 75, 25, 0)
GUISetState(@SW_SHOW)
GUISetState()
$Zeit = (GUICtrlRead($Sekunden)*1000 + GUICtrlRead($Minuten)*60000)
while $Zeit >= 0
GUICtrlSetData($Her, Round($Zeit/1000 ,0) & "sek heruntergefahren")
Switch GUIGetMSG()
Case $GUI_EVENT_Close
ExitLoop
Case $Abbrechen
ExitLoop
EndSwitch
Sleep(90)
$Zeit = $Zeit - 100
WEnd
Switch $Zeit
Case -100
GUIDelete ($Form1)
Shutdown (0)
Case 0.1 to 99999999999
GUIDelete ($Form1)
MsgBox(1,"Info","Vorgang durch Benutzer unterbrochen")
WinSetState($Main,"",@SW_RESTORE)
EndSwitch
Else ;
EndIf
Case Else
EndSwitch
WEnd
GUIDelete()
EndFunc ;==>_Main