billthecreator Posted June 17, 2008 Posted June 17, 2008 i have this program that wont shut down on its given time. it only shuts down when settings are changed and its during the shutdown time expandcollapse popup#include <GUIConstants.au3> #include <Misc.au3> #include <String.au3> #include <File.au3> Global $day, $hour, $apm $file = @ScriptDir&"\data.txt" Opt("TrayMenuMode",3) $sett = TrayCreateItem("Settings...") TrayCreateItem("Version 1.0.0.1") TrayItemSetState(-1, $Tray_Disable) $quit = TrayCreateItem("Quit") $Form1_1 = GUICreate("When to shutdown", 208, 64, 578, 335, BitOR($WS_MINIMIZEBOX,$WS_CAPTION,$WS_POPUP,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS)) $Combo1 = GUICtrlCreateCombo("Sundays", 8, 8, 83, 25) GUICtrlSetData(-1, "Saturdays|Mondays|Tuesdays|Wednesdays|Thursdays","Saturdays") $Combo2 = GUICtrlCreateCombo("1", 112, 8, 41, 25) GUICtrlSetData(-1, "2|3|4|5|6|7|8|9|10|11","6") $Combo3 = GUICtrlCreateCombo("AM", 158, 8, 39, 25) $Button1 = GUICtrlCreateButton("Set", 8, 32, 65, 25) $Label1 = GUICtrlCreateLabel("at", 96, 9, 13, 17) $Button2 = GUICtrlCreateButton("Quit", 144, 32, 57, 25, 0) $Button3 = GUICtrlCreateButton("Cancel", 80, 32, 57, 25, 0) GUISetState(@SW_SHOW) Load() While 1 ;default $setday = 7 $settime = 12 $m = GUIGetMsg() $t = TrayGetMsg() If $t = $quit or $m = $Button2 Then Exit EndIf If $m = $Button3 Then GUISetState(@SW_HIDE) TrayTip("Shutdown"," Shutdown scheduled for "&$day&" at "&$hour&" "&$apm,3,1) TraySetToolTip("SDT: "&$setday&"-"&$settime&".") EndIf If $m = $Button1 Then shutd() EndIf If $setday = @WDAY Then if $settime = @HOUR Then MsgBox(0,"Shutdown","Shutdown in progress",1) Shutdown(5) EndIf EndIf if $t = $sett Then GUISetState(@SW_SHOW) EndIf WEnd Func Apply() $day = guictrlread($Combo1) $hour = guictrlread($Combo2) $apm = guictrlread($Combo3) EndFunc ;==>Apply Func Save() Apply() $Save = _StringEncrypt(1, $day&""&$hour&""&$apm, "Secret") If FileExists($file) Then FileDelete($file) FileWrite($file, $Save) EndFunc ;==>Save Func Load() If FileExists($file) Then $Load = FileRead($file) $Decrypt = _StringEncrypt(0, $Load, "Secret") $Settings = StringSplit($Decrypt, "", 1) GUICtrlSetData($Combo1,"Fridays", $Settings[1]) GUICtrlSetData($Combo2,"12", $Settings[2]) GUICtrlSetData($Combo3,"PM", $Settings[3]) Apply() EndIf EndFunc Func shutd() $day = guictrlread($Combo1) $hour = guictrlread($Combo2) $apm = guictrlread($Combo3) if $day = "Sundays" Then $setday = 1 EndIf if $day = "Mondays" Then $setday = 2 EndIf if $day = "Tuesdays" Then $setday = 3 EndIf if $day = "Wednesdays" Then $setday = 4 EndIf if $day = "Thursdays" Then $setday = 5 EndIf if $day = "Fridays" Then $setday = 6 EndIf if $day = "Saturdays" Then $setday = 7 EndIf if $apm = "AM" Then if $hour = 12 Then $settime = 00 Else $settime = $hour EndIf EndIf if $apm = "PM" Then if $hour = 12 Then $settime = 12 Else $settime = $hour + 12 EndIf EndIf GUISetState(@SW_HIDE) TrayTip("Shutdown"," Shutdown scheduled for "&$day&" at "&$hour&" "&$apm,3,1) TraySetToolTip("SDT: "&$setday&"-"&$settime&".") Save() EndFunc [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap
Zedna Posted August 9, 2008 Posted August 9, 2008 $setday = 7, $settime = 12 was incorectly in main loop expandcollapse popup#include <GUIConstants.au3> #include <Misc.au3> #include <String.au3> #include <File.au3> Opt("TrayMenuMode", 3) Global $day, $hour, $apm Global $setday = 7, $settime = 12 $file = @ScriptDir & "\data.txt" $sett = TrayCreateItem("Settings...") TrayCreateItem("Version 1.0.0.1") TrayItemSetState(-1, $Tray_Disable) $quit = TrayCreateItem("Quit") $Form1_1 = GUICreate("When to shutdown", 208, 64, 578, 335, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS)) $Combo1 = GUICtrlCreateCombo("Sundays", 8, 8, 83, 25) GUICtrlSetData(-1, "Saturdays|Mondays|Tuesdays|Wednesdays|Thursdays", "Saturdays") $Combo2 = GUICtrlCreateCombo("1", 112, 8, 41, 25) GUICtrlSetData(-1, "2|3|4|5|6|7|8|9|10|11", "6") $Combo3 = GUICtrlCreateCombo("AM", 158, 8, 39, 25) $Button1 = GUICtrlCreateButton("Set", 8, 32, 65, 25) $Label1 = GUICtrlCreateLabel("at", 96, 9, 13, 17) $Button2 = GUICtrlCreateButton("Quit", 144, 32, 57, 25, 0) $Button3 = GUICtrlCreateButton("Cancel", 80, 32, 57, 25, 0) GUISetState(@SW_SHOW) Load() While 1 $m = GUIGetMsg() $t = TrayGetMsg() If $t = $quit Or $m = $Button2 Then Exit EndIf If $m = $Button3 Then GUISetState(@SW_HIDE) TrayTip("Shutdown", " Shutdown scheduled for " & $day & " at " & $hour & " " & $apm, 3, 1) TraySetToolTip("SDT: " & $setday & "-" & $settime & ".") EndIf If $m = $Button1 Then shutd() EndIf If $setday = @WDAY Then If $settime = @HOUR Then MsgBox(0, "Shutdown", "Shutdown in progress", 1) Shutdown(5) EndIf EndIf If $t = $sett Then GUISetState(@SW_SHOW) EndIf WEnd Func Apply() $day = GUICtrlRead($Combo1) $hour = GUICtrlRead($Combo2) $apm = GUICtrlRead($Combo3) EndFunc ;==>Apply Func Save() Apply() $Save = _StringEncrypt(1, $day & "†" & $hour & "†" & $apm, "Secret") If FileExists($file) Then FileDelete($file) FileWrite($file, $Save) EndFunc ;==>Save Func Load() If FileExists($file) Then $Load = FileRead($file) $Decrypt = _StringEncrypt(0, $Load, "Secret") $Settings = StringSplit($Decrypt, "†", 1) GUICtrlSetData($Combo1, "Fridays", $Settings[1]) GUICtrlSetData($Combo2, "12", $Settings[2]) GUICtrlSetData($Combo3, "PM", $Settings[3]) Apply() EndIf EndFunc ;==>Load Func shutd() $day = GUICtrlRead($Combo1) $hour = GUICtrlRead($Combo2) $apm = GUICtrlRead($Combo3) If $day = "Sundays" Then $setday = 1 EndIf If $day = "Mondays" Then $setday = 2 EndIf If $day = "Tuesdays" Then $setday = 3 EndIf If $day = "Wednesdays" Then $setday = 4 EndIf If $day = "Thursdays" Then $setday = 5 EndIf If $day = "Fridays" Then $setday = 6 EndIf If $day = "Saturdays" Then $setday = 7 EndIf If $apm = "AM" Then If $hour = 12 Then $settime = 00 Else $settime = $hour EndIf EndIf If $apm = "PM" Then If $hour = 12 Then $settime = 12 Else $settime = $hour + 12 EndIf EndIf GUISetState(@SW_HIDE) TrayTip("Shutdown", " Shutdown scheduled for " & $day & " at " & $hour & " " & $apm, 3, 1) TraySetToolTip("SDT: " & $setday & "-" & $settime & ".") Save() EndFunc ;==>shutd Resources UDF ResourcesEx UDF AutoIt Forum Search
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