erifash Posted December 20, 2004 Share Posted December 20, 2004 (edited) I know, I know... Yet another timed shutdown program! But jut try it out. It can shutdown, log off, reboot, and hibernate! press CTRL+S to bring up shutdown menu press CTRL+A to pause shutdown press CTRL+Z to exit shutdown program Here it is: expandcollapse popup#include <GUIConstants.au3> Opt("TrayIconHide", 1) Singleton("SysMulti v.0.1.7") HotKeySet("^!s", "sd") HotKeySet("^!a", "abort") HotKeySet("^!z", "close") $guiwidth = 282 $guiheight = 253 $code = 9 $hour = 0 $min = 0 $sec = 60 $what = "Shutdown" $com = "" $gui = GUICreate("System Shutdown", $guiwidth, $guiheight, ( @DesktopWidth / 2 ) - ( $guiwidth / 2 ), ( @DesktopHeight / 2 ) - ( $guiheight / 2 )) GUICtrlCreateGroup("Message", 48, 143, 218, 94) GUICtrlCreateLabel("This system is shutting down. Please save all" & @CRLF & "work in progress and log off. Any unsaved" & @CRLF & "changes will be lost. This shutdown was" & @CRLF & "initiated by " & @ComputerName & "\Administrator", 53, 42, 221, 68) $before = GUICtrlCreateLabel("", 53, 121, 127, 12) $time = GUICtrlCreateLabel("", 174, 120, 61, 12) $message = GUICtrlCreateLabel($com, 57, 159, 205, 73) WinSetOnTop($gui, "", 1) GUISetBkColor(0xE0DFE3) GUISetState() sdown(0, 0, 60, "", "Shutdown") Func sdown($hour, $min, $sec, $com, $what) If $sec < 0 Then Exit GUICtrlSetData($before, "Time before " & $what & " :") GUICtrlSetData($message, $com) While 1 GUICtrlSetData($time, $hour & ":" & $min & ":" & $sec) Sleep(1000) $sec = $sec - 1 If $sec = 0 and $min >= 1 Then $sec = 60 $min = $min - 1 EndIf If $min = 0 and $hour >= 1 Then $min = 60 $hour = $hour - 1 EndIf If $sec = 0 Then sdownhut($code) Wend EndFunc;==>sdown Func sdownhut($code) Shutdown($code) While 1 Sleep(10 Wend EndFunc Func sd() HotKeySet("^!s") HotKeySet("^!a") $inputstyle = $ES_NUMBER $editstyle = $ES_MULTILINE + $ES_WANTRETURN $sd = GUICreate("System Shutdown", $guiwidth, $guiheight, ( @DesktopWidth / 2 ) - ( ( $guiwidth / 2 ) + $guiwidth + 6 ), ( @DesktopHeight / 2 ) - ( $guiheight / 2 )) $shutdown = GUICtrlCreateCheckbox("Shutdown", 05, 000) $logoff = GUICtrlCreateCheckbox("Log Off", 05, 020) $restart = GUICtrlCreateCheckbox("Restart", 05, 040) $hibernate = GUICtrlCreateCheckbox("Hibernate", 05, 060) $h = GUICtrlCreateInput("0", 05, 100, 100, 20, $inputstyle) $m = GUICtrlCreateInput("0", 05, 125, 100, 20, $inputstyle) $s = GUICtrlCreateInput("60", 05, 150, 100, 20, $inputstyle) $c = GUICtrlCreateEdit("", 05, 175, 170, 70) GUICtrlCreateLabel("Hours", 110, 100, 100, 15) GUICtrlCreateLabel("Minutes", 110, 125, 100, 15) GUICtrlCreateLabel("Seconds", 110, 150, 100, 15) GUICtrlCreateLabel("Comment", 180, 175, 100, 15) $set = GUICtrlCreateButton("Set", 200, 225, 70, 20) WinSetOnTop($sd, "", 1) GUISetBkColor(0xE0DFE3) GUICtrlSetState($shutdown, $GUI_CHECKED) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() HotKeySet("^!s", "sd") HotKeySet("^!a", "abort") sdown($hour, $min, $sec, $com, $what) Case $msg = $set $hour = GUIRead($h) $min = GUIRead($m) $sec = GUIRead($s) If $sec = 0 and $min > 0 Then $sec = 60 $min = $min - 1 EndIf HotKeySet("^!s", "sd") HotKeySet("^!a", "abort") While $sec > 60 $sec = $sec - 60 $min = $min + 1 Wend While $min > 60 $min = $min - 60 $hour = $hour + 1 Wend $com = GUIRead($c) GUIDelete() sdown($hour, $min, $sec, $com, $what) Case $msg = $shutdown $what = "Shutdown" $code = 9 GUICtrlSetState($logoff, $GUI_UNCHECKED) GUICtrlSetState($restart, $GUI_UNCHECKED) GUICtrlSetState($hibernate, $GUI_UNCHECKED) Case $msg = $logoff $what = "Log Off" $code = 0 GUICtrlSetState($shutdown, $GUI_UNCHECKED) GUICtrlSetState($restart, $GUI_UNCHECKED) GUICtrlSetState($hibernate, $GUI_UNCHECKED) Case $msg = $restart $what = "Restart" $code = 2 GUICtrlSetState($shutdown, $GUI_UNCHECKED) GUICtrlSetState($logoff, $GUI_UNCHECKED) GUICtrlSetState($hibernate, $GUI_UNCHECKED) Case $msg = $hibernate $what = "Hibernate" $code = 70 GUICtrlSetState($shutdown, $GUI_UNCHECKED) GUICtrlSetState($logoff, $GUI_UNCHECKED) GUICtrlSetState($restart, $GUI_UNCHECKED) EndSelect Sleep(10) Wend EndFunc Func Singleton($semaphore) Local $ERROR_ALREADY_EXISTS = 183 DllCall("kernel32.dll", "int", "CreateSemaphore", "int", 0, "long", 1, "long", 1, "str", $semaphore) Local $lastError = DllCall("kernel32.dll", "int", "GetLastError") If $lastError[0] = $ERROR_ALREADY_EXISTS Then Exit -1 EndFunc;==>Singleton Func abort() While 1 Sleep(10) Wend EndFunc Func close() Exit EndFunc Any comments/questions would be greatly appreciated! Edited December 20, 2004 by erifash My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
killaz219 Posted December 20, 2004 Share Posted December 20, 2004 With no link to it, how can I test it? Link to comment Share on other sites More sharing options...
erifash Posted December 20, 2004 Author Share Posted December 20, 2004 sry about that! My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
killaz219 Posted December 20, 2004 Share Posted December 20, 2004 Good, except I had to comment out some stuff and add a call for sd() just so I could test the admin thing. Link to comment Share on other sites More sharing options...
erifash Posted December 20, 2004 Author Share Posted December 20, 2004 Good, except I had to comment out some stuff and add a call for sd() just so I could test the admin thing.<{POST_SNAPBACK}>0 hours, 0 minutes, and 60 seconds is the default. Use the hotkeys said earlier to modify the comment, hours, minutes, seconds, etc...press CTRL+S to bring up shutdown menupress CTRL+A to pause shutdownpress CTRL+Z to exit shutdown program My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
killaz219 Posted December 20, 2004 Share Posted December 20, 2004 0 hours, 0 minutes, and 60 seconds is the default. Use the hotkeys said earlier to modify the comment, hours, minutes, seconds, etc...<{POST_SNAPBACK}>Oops, didn't notice that. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now