#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#region ### START Koda GUI section ### Form=
Local $bool_shutdown = False
$Form1 = GUICreate("定时关机", 203, 133, -1, -1)
$Group1 = GUICtrlCreateGroup("时间设置", 8, 8, 185, 65)
$Combo1 = GUICtrlCreateCombo("", 16, 32, 41, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|00", "23")
$Label1 = GUICtrlCreateLabel("时", 64, 32, 36, 17)
$Combo2 = GUICtrlCreateCombo("", 104, 32, 41, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetData(-1, "05|10|15|20|25|30|35|40|45|50|55|00", "00")
$Label2 = GUICtrlCreateLabel("分", 152, 32, 36, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Checkbox1 = GUICtrlCreateCheckbox("开机启动", 10, 88, 100, 33)
$Button1 = GUICtrlCreateButton("执行", 120, 88, 60, 35)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)
$item1 = TrayCreateItem("退出程序")
TrayItemSetOnEvent(-1, "_Exit")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
_Exit()
Case -4
GUISetState(@SW_HIDE, $Form1)
Opt("TrayIconHide", 0)
Case $Button1
If GUICtrlRead($Button1) = "执行" Then ; if $bool_shutdown = False ; 也可以
GUICtrlSetData($Button1, "取消")
AdlibRegister('_shutdown', 50)
$bool_shutdown = True
Else
GUICtrlSetData($Button1, "执行")
AdlibUnRegister('_shutdown')
$bool_shutdown = False
EndIf
EndSwitch
WEnd
Func _shutdown()
$hour = GUICtrlRead($Combo1)
$min = GUICtrlRead($Combo2)
$current_time = StringSplit(_NowTime(4), ':')
If Not IsArray($current_time) Then Return
If $hour = $current_time[1] And $min = $current_time[2] Then
MsgBox(0, 'msg', '执行成功!', 0, $Form1)
;Shutdown(0 + 4)
EndIf
EndFunc ;==>_shutdown
Func _Exit()
If $bool_shutdown = True Then Return MsgBox(16, 'Err', '请先取消定时关机计划!', 0, $Form1)
Exit
EndFunc ;==>_Exit