This is my contribution to the fight against excessive power consumption.
The following command line triggers my script to start at 10pm each night.
Code:
AT 22:00 /Every:M,T,W,Th,F,S,Su START Shutdown.ahk /d C:\Users\Use
r\Documents
A tooltip is displayed and moves around the screen to alert the user that the computer is scheduled to shut down. The user then has 5 minutes to move the mouse, or to press a key before the computer shuts down. If the user does press a key or move the move, a 15minute timer begins before the tooltips reappear and the 5 minute countdown starts.
Code:
Gosub, SetTimer
SetTimer:
SetTimer, SetTimer, Off
SetTimer, Tooltip, 3000
Tooltip:
CoordMode, ToolTip, Screen
n++
Random, xm, 1, 1000
Random, ym, 1, 500
MousegetPos, X, Y
Tooltip, `n`n This system is scheduled to shut down. Press any key to abort.`n`n., %xm%,%ym%
Sleep, 3000
MousegetPos, Xn, Xn
If n = 100
GoSub, Shutdown
If (Abs(X - Xn) > 30 || Abs(Y - Yn) > 30)
Gosub, Another15
Return
Another15:
Tooltip
SetTimer, ToolTip, Off
n = 0
SetTimer, SetTimer, 900000
return
Shutdown:
Shutdown, 1
return
~a::
~b::
~c::
~d::
~e::
~f::
~g::
~h::
~i::
~j::
~k::
~l::
~m::
~n::
~o::
~p::
~q::
~r::
~s::
~t::
~u::
~v::
~w::
~x::
~y::
~z::
~Space::
~Enter::
~Esc::
~BS::
~Del::
~Ins::
~Home::
~End::
~PgUp::
~PgDn::
~Up::
~Down::
~Left::
~Right::
~ScrollLock::
~CapsLock::
~NumLock::
~1::
~2::
~3::
~4::
~5::
~6::
~7::
~8::
~9::
~0::
GoSub, Another15
return
I apologize if my code is difficult to read; I intended this for personal use and only publish it as an afterthought. Thanks to Delta for his Tooltip dictionary from which i derived my mouse movement 'hotkey.'
If there is a nicer way of doing "any key press", i would appreciate the help.