|
本帖最後由 maodou 於 2020-6-16 12:42 編輯
轉成繁體字是可以的... (UTF-8)
- #Region ;**** 由 AccAu3Wrapper_GUI 建立指令 ****
- #AccAu3Wrapper_Icon=111.ico ;ICO檔案自己準備
- #AccAu3Wrapper_OutFile=自動關機助手.exe
- #AccAu3Wrapper_UseX64=n
- #AccAu3Wrapper_Res_Comment=
- #AccAu3Wrapper_Res_Description=
- #AccAu3Wrapper_Res_Fileversion=1.0.0.1
- #AccAu3Wrapper_Res_LegalCopyright=
- #AccAu3Wrapper_Res_Language=2052
- #AccAu3Wrapper_Res_requestedExecutionLevel=None
- #EndRegion ;**** 由 AccAu3Wrapper_GUI 建立指令 ****
- #Region ;**** 參數建立于 ACNWrapper_GUI ****
- #EndRegion ;**** 參數建立于 ACNWrapper_GUI ****
- #include <GUIConstantsEx.au3>
- #include <StaticConstants.au3>
- #include <WindowsConstants.au3>
- #include <ButtonConstants.au3>
- #include <ComboConstants.au3>
- #include <GUIConstants.au3>
- #include <DateTimeConstants.au3>
- #Include <Constants.au3>
- $Exists = "關機助手";判斷是否只執行一個程式
- If WinExists($Exists) Then
- MsgBox(32,"溫馨提醒您:","程式已經執行!")
- Exit
- EndIf
-
- ;AutoItWinSetTitle($Exists);修改程式視窗的標題名
- FileCreateShortcut(@AutoItExe,@DesktopCommonDir&"定時工具");自動在桌面建立快捷方式!
- $Combo1 = GUICtrlCreateCombo("", 120, 95, 80, 25);組合列表
- $R1 = ""
- $T1 = ""
- $T2 = ""
- $T3 = ""
- $T4 = ""
- $S1 = ""
- $W1="0"
- $W2="0"
- $W3="0"
- $W4="0"
- $W5="0"
- $W6="0"
- $W7="0"
- $Form0= GUICreate("關機助手", 420, 380, 500, 300);前面二個是大小,後面二個是座標
- $Group1 = GUICtrlCreateGroup("關機時間設定(預設為每天)", 20, 110, 380, 95);前面二個是框座標,後面是大小
- GUICtrlSetColor(-1,0x666666)
- $Checkbox1 = GUICtrlCreateCheckbox("星期一", 40, 130, 65, 25);前面二個是座標,後面是自己佔用大小
- $Checkbox2 = GUICtrlCreateCheckbox("星期二", 110, 130, 65, 25)
- $Checkbox3 = GUICtrlCreateCheckbox("星期三", 180, 130, 65, 25)
- $Checkbox4 = GUICtrlCreateCheckbox("星期四", 250, 130, 65, 25)
- $Checkbox5 = GUICtrlCreateCheckbox("星期五", 320, 130, 65, 25)
- $Checkbox6 = GUICtrlCreateCheckbox("星期六", 40, 170, 65, 25)
- $Checkbox7 = GUICtrlCreateCheckbox("星期日", 110, 170, 65, 25)
- $Checkbox8 = GUICtrlCreateCheckbox("每日", 180, 170, 50, 25)
- $Label1 = GUICtrlCreateLabel("時間設定:", 240, 175, 65, 25)
- GUICtrlSetState($Checkbox8, $GUI_CHECKED)
- $Date1 = GUICtrlCreateDate("", 290, 170, 80, 20, BitOR($DTS_UPDOWN,$DTS_TIMEFORMAT,$WS_TABSTOP));時間選擇控制元件
- GUICtrlCreateGroup("", -99, -99, 1, 1)
- $Group2 = GUICtrlCreateGroup("關機操作(預設強制重啟)", 20, 210, 380, 50)
- GUICtrlSetColor(-1,0x666666)
- $Radio1 = GUICtrlCreateRadio("重啟", 60, 230, 65, 25)
- $Radio2 = GUICtrlCreateRadio("關機", 140, 230, 65, 25)
- $Radio3 = GUICtrlCreateRadio("強制重啟", 210, 230, 65, 25)
- $Radio4 = GUICtrlCreateRadio("強制關機", 285, 230, 65, 25)
- GUICtrlSetState($Radio3, $GUI_CHECKED)
- GUICtrlCreateGroup("", -99, -99, 1, 1)
- $Group3 = GUICtrlCreateGroup("", 20, 13, 380, 90)
- $Label2 = GUICtrlCreateLabel("關機小程式", 140, 0, 120, 17)
- GUICtrlSetColor(-1,0xbb0033);美化字型顏色
- $Label3 = GUICtrlCreateLabel("", 290, 0, 108, 18)
- GUICtrlSetColor(-1,0x440011)
- $Label4 = GUICtrlCreateLabel("每週:", 30, 30, 360, 30)
- $Label5 = GUICtrlCreateLabel("每天:", 30, 50, 100, 20)
- $Label6 = GUICtrlCreateLabel("執行:", 30, 70, 80, 20)
- GUICtrlCreateGroup("", -99, -99, 1, 1)
- $Button1 = GUICtrlCreateButton("應用設定", 120, 270, 65, 25)
- GUICtrlSetColor(-1,0x110033)
- $Button2 = GUICtrlCreateButton("重置設定", 250, 270, 65, 25)
- GUICtrlSetColor(-1,0x110033)
- GUICtrlCreateGroup("", -99, -99, 1, 1)
- $Group4 = GUICtrlCreateGroup("", 20, 295, 380, 75)
- $Button3 = GUICtrlCreateButton("隨系統啟動", 27, 310, 75, 25)
- $Button4 = GUICtrlCreateButton("去除自啟", 102, 310, 75, 25)
- $Button5 = GUICtrlCreateButton("重啟主機", 177, 310, 75, 25)
- $Button6 = GUICtrlCreateButton("關閉主機", 252, 310, 75, 25)
- $Button7 = GUICtrlCreateButton("預留", 327, 310, 40, 25)
- $Button8 = GUICtrlCreateButton("隱藏視窗", 27, 340, 75, 25)
- $Button9 = GUICtrlCreateButton("系統啟動免登錄密碼", 102, 340, 120, 25)
- GUISetState(@SW_SHOW)
- #EndRegion ### END Koda GUI section ###
- HotKeySet("^!f", "hotkey")
- Opt("TrayAutoPause",0)
- If RegRead("HKEY_LOCAL_MACHINESOFTWARETIME","時間") <> "" Then;讀取註冊表指定的值
- Opt("TrayMenuMode",0)
- Opt("TrayIconHide",0)
-
- EndIf
- While 1
- $Tray = TrayGetMsg();得到一個系統托盤圖示專案產生的事件.
- $msg = GUIGetMsg(1);捕獲視窗消
- Select
- Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $Form0;如果點下的是$GUI_EVENT_CLOSE(關閉)
- Exit
- Case $msg[0] = $Button3
- RegRun();操作Func RegRun()設定事件
- MsgBox(0,"溫馨提醒您:","已經在註冊表寫入開機自啟動,請勿移動本程式到別的位置.")
- Case $msg[0] = $Button4
- RegDelete("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRun","定時工具")
- MsgBox(0,"溫馨提醒您:","開機自動啟動已從註冊表中移除")
- Case $msg[0] = $Button5
- Shutdown(1);關機
- Case $msg[0] = $Button6
- Shutdown(2);重啟
- Case $msg[0] = $Button7
- MsgBox(32,"溫馨提醒您:","此視窗為其他功能預留。")
- Case $msg[0] = $Button8
- Opt("TrayIconHide", 0) ;隱藏托盤區圖示
- Opt("TrayMenuMode",1)
- GUISetState(@SW_HIDE,$Form0)
- Case $msg[0] = $Button9
- Run("rundll32.exe netplwiz.dll,UsersRunDll")
- Run("control userpasswords2")
- Case $msg[0] = $GUI_EVENT_MINIMIZE;對話方塊視窗被最小化
- Opt("TrayMenuMode",1)
- GUISetState(@SW_HIDE,$Form0)
- TrayTip("關機助手","點選還原!",5,1)
- Case $msg[0] = $Button2
- RegDelete("HKEY_LOCAL_MACHINESOFTWARETIME")
- GUICtrlSetData($Label4,"執行時間: 暫時未設定定時任務")
- TrayTip("通知您","目前任務已經清理完畢,可重新設定.",1,2)
- Case $msg[0] = $Button1
- RegDelete("HKEY_LOCAL_MACHINESOFTWARETIME")
- $SET = GUICtrlRead($Date1)
- If StringLen($SET) = 7 Then
- $SET = "0"&$SET
- EndIf
- If GUICtrlRead($Radio1,0)=1 Then
- $S1="重啟"
- ElseIf GUICtrlRead($Radio2,0)=1 Then
- $S1="關機"
- ElseIf GUICtrlRead($Radio3,0)=1 Then
- $S1="強制重啟"
- ElseIf GUICtrlRead($Radio4,0)=1 Then
- $S1="強制關機"
- ElseIf GUICtrlRead($Radio1,0)<>1 Or GUICtrlRead($Radio2,0)<>1 Or GUICtrlRead($Radio3,0)<>1 Or GUICtrlRead($Radio3,0)<>1 Then
- $S1="強制重啟"
- EndIf
- $W1=GUICtrlRead($Checkbox1,1)
- $W2=GUICtrlRead($Checkbox2,0)
- $W3=GUICtrlRead($Checkbox3,0)
- $W4=GUICtrlRead($Checkbox4,0)
- $W5=GUICtrlRead($Checkbox5,0)
- $W6=GUICtrlRead($Checkbox6,0)
- $W7=GUICtrlRead($Checkbox7,0)
- $W8=GUICtrlRead($Checkbox8,0)
- ;ToolTip("1" & $W1 & "2" & $W2 & "3" & $W3 & "4" & $W4 & "5"& $W5& "6"& $W6 & "7"& $W7& "8" & $W8 & "......",0,0)
- Sleep(1000)
- If $W8=1 And ($W1=1 Or $W2=1 Or $W3=1 Or $W4=1 Or $W5=1 Or $W6=1 Or $W7=1 ) then
- $WEEK8="每日"
- RegWrite("HKEY_LOCAL_MACHINESOFTWARETIME","每日","REG_SZ",$WEEK8)
- Else
- $WEEK8="每日"
- RegWrite("HKEY_LOCAL_MACHINESOFTWARETIME","每日","REG_SZ",$WEEK8)
- EndIf
- If $W1=1 Then
- $WEEK1="星期一"
- RegWrite("HKEY_LOCAL_MACHINESOFTWARETIME","星期一","REG_SZ",$WEEK1)
- EndIf
- If $W2=1 Then
- $WEEK2="星期二"
- RegWrite("HKEY_LOCAL_MACHINESOFTWARETIME","星期二","REG_SZ",$WEEK2)
- EndIf
- If $W3=1 Then
- $WEEK3="星期三"
- RegWrite("HKEY_LOCAL_MACHINESOFTWARETIME","星期三","REG_SZ",$WEEK3)
- EndIf
- If $W4=1 Then
- $WEEK4="星期四"
- RegWrite("HKEY_LOCAL_MACHINESOFTWARETIME","星期四","REG_SZ",$WEEK4)
- EndIf
- If $W5=1 Then
- $WEEK5="星期五"
- RegWrite("HKEY_LOCAL_MACHINESOFTWARETIME","星期五","REG_SZ",$WEEK5)
- EndIf
- If $W6=1=1 Then
- $WEEK6="星期六"
- RegWrite("HKEY_LOCAL_MACHINESOFTWARETIME","星期六","REG_SZ",$WEEK6)
- EndIf
- If $W7=1=1 Then
- $WEEK7="星期日"
- RegWrite("HKEY_LOCAL_MACHINESOFTWARETIME","星期日","REG_SZ",$WEEK7)
- EndIf
-
- RegWrite("HKEY_LOCAL_MACHINESOFTWARETIME","時間","REG_SZ",$SET)
- RegWrite("HKEY_LOCAL_MACHINESOFTWARETIME","事件","REG_SZ",$S1)
-
-
- TrayTip("通知","已經設定完成!請勿關閉程式,否則設定將不起作用.",1,2)
- EndSelect
-
- Switch $Tray
- Case $TRAY_EVENT_PRIMARYDOWN;按下了滑鼠左鍵
- GUISetState(@SW_SHOW);啟用指定視窗並使其以目前大小和位置資訊顯示
- EndSwitch
- $T1 = RegRead("HKEY_LOCAL_MACHINESOFTWARETIME","時間")
- $R0 = RegRead("HKEY_LOCAL_MACHINESOFTWARETIME","事件")
- $WK1 = RegRead("HKEY_LOCAL_MACHINESOFTWARETIME","星期一")
- $WK2 = RegRead("HKEY_LOCAL_MACHINESOFTWARETIME","星期二")
- $WK3 = RegRead("HKEY_LOCAL_MACHINESOFTWARETIME","星期三")
- $WK4 = RegRead("HKEY_LOCAL_MACHINESOFTWARETIME","星期四")
- $WK5 = RegRead("HKEY_LOCAL_MACHINESOFTWARETIME","星期五")
- $WK6 = RegRead("HKEY_LOCAL_MACHINESOFTWARETIME","星期六")
- $WK7 = RegRead("HKEY_LOCAL_MACHINESOFTWARETIME","星期日")
- $WK8 = RegRead("HKEY_LOCAL_MACHINESOFTWARETIME","每日")
-
- If $T2 <> $T1 Or $R0 <> $R1 Then;"<>"比較是否不相等,不相等該表達返回1否則返回0
- $R1 = $R0
- $T2 = $T1
- If $WK8="每日" Then
- GUICtrlSetData($Label4,"每週:"&$WK8&" "&$T1&"("&$R0&")")
- Else
- GUICtrlSetData($Label4,"每週: "&$WK1&" "&$WK2&" "&$WK3&" "&$WK4&" "&$WK5&" "&$WK6&" "&$WK7&" "&$T1&"("&$R0&")")
- EndIf
- EndIf
- $T3 = @HOUR&":"&@MIN&":"&@SEC;$T3等於目前時間
- If $T3 <> $T4 then
- $T4 = $T3
- GUICtrlSetData($Label3,""&@MON&"月"&@MDAY&"日 "&@HOUR&":"&@MIN&":"&@SEC&" ");修改指定控制元件的相關數據
- EndIf
- If $T1 = $T3 Then
- If $R0 = "關機" Then;讀取註冊表值,當$RO值等於組合列表"關機"時,則執行$RNOW = 1
- $RNOW = 1;關機事件
- ElseIf $R0 = "重啟" Then
- $RNOW = 2;重啟事件
- ElseIf $R0 = "待機" Then
- $RNOW = 32;待機事件
- ElseIf $R0 = "休眠" Then
- $RNOW = 64;休眠事件
- ElseIf $R0 = "強制關機" Then
- $RNOW = 5;強行關機
- ElseIf $R0 = "強制重啟" Then
- $RNOW = 6;強行重啟
- EndIf
- Shutdown($RNOW);shutdown關機事件
- EndIf
- If RegRead("HKEY_LOCAL_MACHINESOFTWARETIME","時間") <> "" Then
- $T5 = StringReplace($T1,":","");替換字串中的指定子串
- $T6 = StringReplace($T3,":","")
- If StringMid($T5,1,2)-StringMid($T6,1,2) = 0 Then
- If StringMid($T5,3,2) - StringMid($T6,3,2) = 0 Then
- If $T5-$T6 > 0 Then
- TrayTip("溫馨提醒您:","還有"&$T5-$T6&"秒開始執行關機程式.....",10,1)
- EndIf
- Elseif StringMid($T5,3,2)-StringMid($T6,3,2) = 1 Then
- If StringMid($T5,5,2)+60-StringMid($T6,5,2) > 0 Then
- TrayTip("溫馨提醒您:","還有"&StringMid($T5,5,2)+60-StringMid($T6,5,2)&"秒開始執行關機程式.....",10,1)
- EndIf
- EndIf
- EndIf
- EndIf
- WEnd
- Func RegRun();修改註冊表,新增程式開機自啟動項
- dim $Run='HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRun'
- RegWrite($Run,'定時工具','REG_SZ',@AutoItExe);@AutoItExe目前指令碼的完整路徑.
- EndFunc;
- Func hotkey()
- Opt("TrayIconHide", 1) ;隱藏托盤區圖示
- Opt("TrayMenuMode",0)
- GUISetState(@SW_SHOW,$Form0)
- EndFunc;
複製代碼 |
|