; Name:倒计时关机
; Version:1.0
; Author:lyuchen
; E-mail:lyuchen@sohu.com

#Persistent
#SingleInstance,Force

Gui, Margin, 5, 5
Gui, Font, S10
Gui, +AlwaysOnTop -MaximizeBox -MinimizeBox
Gui, Add, Radio, checked vMyRadio, 计时
Gui, Add, Radio, x+25, 立即关机
Gui, Add, Edit, x5 w65 h25 +0x2000 +Center vH -Limit, 00
Gui, Add, Text, x+3 w10 h25 +Center, :
Gui, Add, Edit, x+3 w65 h25 +0x2000 +Center vM -Limit, 00
Gui, Add, Button, x5 y+5 w70 h25 Default, OK
Gui, Add, Button, x+6 w70 h25 , Cancel
Gui, Show, AutoSize Center, 倒计时关机

; OnExit Tray_Exit
Goto, Menu_Show
Return

GuiClose:
ButtonCancel:
ExitApp
Return

ButtonOK:
Gui,Submit
time_s = %A_TickCount%
If MyRadio = 1
  time := H*3600000+M*60000
Else
  time := (H-A_Hour)*3600000+(M-A_Min)*60000
time_a += time/1000, Sec
FormatTime, time_c, %time_a%,HH:mm
Menu, Tray, Tip, 倒计时关机 %time_c%
Sleep, %time%
Run, %A_WinDir%\system32\shutdown.exe -s -f,,Hide
Sleep, 180000
Shutdown, 5
Return

GuiEscape:
Tray_Exit:
If A_ExitReason not in Logoff,Shutdown
{
Run %A_WinDir%\system32\shutdown.exe -a,,Hide
}
ExitApp
Return

Menu_Show:
{
Menu, Tray, NoStandard
Menu, Tray, Click, 1
Menu, Tray, Tip, 倒计时关机
Menu, Tray, Add, 倒计时关机, Tray_Show
Menu, Tray, ToggleEnable, 倒计时关机
Menu, Tray, Default, 倒计时关机
Menu, Tray, Add
Menu, Tray, Add, 时间(&S), Tray_Time
Menu, Tray, Add
Menu, Tray, Add, 重启(&R), Tray_Reload
Menu, Tray, Add, 退出(&X), Tray_Exit
}
Return

Tray_Show:
Menu, Tray, Show
return

Tray_Reload:
Reload
Return

Tray_Time:
FormatTime, time_b, %time_a%,MM月dd日HH时mm分
miao:=(time-(A_TickCount-time_s))//1000, dd:=miao//86400, hh:=Mod(miao,86400)//3600, mm:=Mod(Mod(miao,86400),3600)//60, ss:=Mod(Mod(Mod(miao,86400),3600),60)
If hh < 10
  hh :=0 hh
If mm < 10
  mm :=0 mm
If ss < 10
  ss :=0 ss
MsgBox, 262192, 倒计时关机, 剩余:`n%dd%天%hh%时%mm%分%ss%秒`n到时:`n%time_b%
Return

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。