#include <GUIConstants.au3>
#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\my documents\reboot.kxf
Global $var = ""
Global $var1 = ""
Global $var2 = ""
Global $var3 = "",$boot1
;Global $time = 10
;$var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "test")
$Form1_1 = GUICreate("Reboot", 633, 447, 191, 133)
$Label1 = GUICtrlCreateLabel("Auto Reboot", 112, 8, 368, 81)
GUICtrlSetFont(-1, 48, 800, 2, "Book Antiqua")
$Label2 = GUICtrlCreateLabel("Reboot Times:", 112, 160, 138, 26)
GUICtrlSetFont(-1, 14, 400, 0, "Lucida Sans")
$Label3 = GUICtrlCreateLabel("Reboot Delay:", 113, 210, 133, 26)
GUICtrlSetFont(-1, 14, 400, 0, "Lucida Sans")
$Label4 = GUICtrlCreateLabel("Current Date:", 45, 354, 129, 26)
GUICtrlSetFont(-1, 14, 400, 0, "Lucida Sans")
$Label5 = GUICtrlCreateLabel("Current Time:", 349, 353, 133, 26)
GUICtrlSetFont(-1, 14, 400, 0, "Lucida Sans")
$Label6 = GUICtrlCreateLabel("OS Version :", 44, 397, 135, 26)
GUICtrlSetFont(-1, 14, 400, 0, "Lucida Sans")
$Label7 = GUICtrlCreateLabel("OS Language:", 354, 399, 129, 26)
GUICtrlSetFont(-1, 14, 400, 0, "Lucida Sans")
$start = GUICtrlCreateButton("Start", 104, 272, 121, 49, 0)
GUICtrlSetFont(-1, 24, 800, 0, "Constantia")
$cancel = GUICtrlCreateButton("Cancel", 367, 272, 121, 49, 0)
GUICtrlSetFont(-1, 24, 800, 0, "Constantia")
$Input1 = GUICtrlCreateInput("Input1", 256, 160, 97, 30)
GUICtrlSetFont(-1, 14, 800, 2, "Lucida Sans")
$Input2 = GUICtrlCreateInput("Input2", 256, 204, 97, 30)
GUICtrlSetFont(-1, 14, 800, 2, "Lucida Sans")
$Label8 = GUICtrlCreateLabel("设置次数", 360, 165, 88, 26)
GUICtrlSetFont(-1, 14, 800, 2, "Lucida Sans")
$Label9 = GUICtrlCreateLabel("重启延迟(秒)", 362, 206, 123, 26)
GUICtrlSetFont(-1, 14, 800, 2, "Lucida Sans")
$save = GUICtrlCreateButton("Save", 257, 243, 81, 49, 0)
GUICtrlSetFont(-1, 24, 800, 0, "Constantia")
$Progress1 = GUICtrlCreateProgress(104, 84, 385, 17)
$Label14 = GUICtrlCreateLabel("Current Times:", 104, 104, 200, 28)
GUICtrlSetFont(-1, 15, 800, 0, "Constantia")
$Label15 = GUICtrlCreateLabel("", 254, 104, 200, 28)
GUICtrlSetFont(-1, 15, 800, 0, "Constantia")
$Label18 = GUICtrlCreateLabel("", 304, 104, 200, 28)
GUICtrlSetFont(-1, 15, 800, 0, "Constantia")
$Label16 = GUICtrlCreateLabel("", 354, 104, 200, 28)
GUICtrlSetFont(-1, 15, 800, 0, "Constantia")
$Label10 = GUICtrlCreateLabel("", 182, 351, 107, 28)
GUICtrlSetFont(-1, 15, 800, 0, "Constantia")
$Label11 = GUICtrlCreateLabel("", 488, 351, 107, 28)
GUICtrlSetFont(-1, 15, 800, 0, "Constantia")
$Label17 = GUICtrlCreateLabel("", 538, 351, 107, 28)
GUICtrlSetFont(-1, 15, 800, 0, "Constantia")
$Label12 = GUICtrlCreateLabel("", 182, 396, 107, 28)
GUICtrlSetFont(-1, 15, 800, 0, "Constantia")
$Label13 = GUICtrlCreateLabel("", 488, 397, 115, 28)
GUICtrlSetFont(-1, 15, 800, 0, "Constantia")
GUISetState(@SW_SHOW)
AdlibEnable("_timer", 1000)
#EndRegion ### END Koda GUI section ###
$OSVER = @OSVersion
GUICtrlSetData($Label12, $OSVER)
$TIME = @HOUR & " :" & @MIN
GUICtrlSetData($Label11, $TIME)
$SEC = ":" & @SEC
GUICtrlSetData($Label17, $SEC)
$OSLANGE = @OSLang
If $OSLANGE = 0804 Then
GUICtrlSetData($Label13, "中文")
EndIf
If $OSLANGE = 0409 Then
GUICtrlSetData($Label13, "英文")
EndIf
If $OSLANGE = 041 Then
GUICtrlSetData($Label13, "日文")
EndIf
$date = @YEAR & "-" & @MON & "-" & @MDAY
GUICtrlSetData($Label10, $date)
$times = IniRead("config.ini", "BOOT", "times", "")
GUICtrlSetData($Input1, $times)
$delay = IniRead("config.ini", "BOOT", "delay", "")
GUICtrlSetData($Input2, $delay)
$boot = IniRead("config.ini", "REBOOT", "rebooted", "")
If $boot = $times Then
_box()
Else
GUICtrlSetData($Label15, $boot)
GUICtrlSetData($Label16, "Rebooting...")
_start()
EndIf
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1_1, "int", 1000, "long", 0x00090000)
ExitLoop
Case $save
_wrini()
Case $start
;_start()
Case $cancel
;_start()
EndSwitch
WEnd
Func _wrini()
$times1 = GUICtrlRead($Input1)
$delay1 = GUICtrlRead($Input2)
IniWrite("config.ini", "BOOT", "times", $times1)
IniWrite("config.ini", "BOOT", "delay", $delay1)
EndFunc ;==>_wrini
;_start()
Func _start()
While $boot <= $times
$leijia = $boot + 1
IniWrite("config.ini", "REBOOT", "rebooted", $leijia)
ExitLoop
WEnd
EndFunc ;==>_start
Func _box()
IniWrite("config.ini", "REBOOT", "rebooted", "0")
$Form1 = GUICreate("Reboot", 633, 447, 193, 125)
$Group1 = GUICtrlCreateGroup("Information", 96, 72, 457, 225)
GUICtrlSetFont(-1, 16, 800, 2, "Arial Black")
$Label1 = GUICtrlCreateLabel("Auto Reboot Complete!!!", 128, 176, 391, 45)
GUICtrlSetFont(-1, 22, 800, 0, "Arial Black")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button5 = GUICtrlCreateButton("O K", 192, 336, 249, 57, 0)
GUICtrlSetFont(-1, 26, 400, 0, "Impact")
GUICtrlSetData($Label15, $boot)
GUICtrlSetData($Label16, "Reboot Success")
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
ExitLoop
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 1000, "long", 0x00090000)
Case $nMsg = $GUI_EVENT_PRIMARYDOWN
AdlibDisable()
GUICtrlSetState($Progress1, $GUI_DISABLE)
Case $Button5
Exit
EndSwitch
WEnd
EndFunc ;==>_box
Func _timer()
$boot -= 1
$boot1+=1
GUICtrlSetData($Label18, $boot)
GUICtrlSetData($Progress1, $boot1/IniRead("config.ini", "REBOOT", "rebooted", "") *100)
If $boot1=IniRead("config.ini", "REBOOT", "rebooted", "") Then AdlibDisable("_timer")
;If $time <= 10 Then Exit
EndFunc ;==>_timer