I have made a few small changes to your code. This is my first post here. I have made it so that you can keep it running All the time without consuming too many resources. I have gotten rid of the long Sleep.
Thank you for this nice script!
#NoTrayIcon
Return
CheckMouseMoved:
MouseGetPos, xMouseNow, yMouseNow
If ( ( xMouseNow != xMouse ) or ( yMouseNow != yMouse ) )
{
xMouseChange := ( xMouseNow - xMouse ) * ( xMouseNow - xMouse ) ;squared to always be positive values
yMouseChange := ( yMouseNow - yMouse ) * ( yMouseNow - yMouse )
If ( ( xMouseChange > 100 ) or ( yMouseChange > 100 ) ) ;sqrt of 100 = 10 pixels of movement
{
Gosub, AbortPrompt
}
If ( KeepItOn != 1 )
{
GoSub, TurnMonitorOff
SetTimer, CheckMouseMoved, 500
}
}
Return
TurnMonitorOff:
SendMessage, 0x112, 0xF170, 2,, Program Manager ; Turn Monitor Off
MouseGetPos, xMouse, yMouse
MouseGetPos, xMouseNow, yMouseNow
Return
AbortPrompt:
KeepItOn = 0
MsgBox,, ABORT?, Press OK to keep screen on:, 5
IfMsgBox, OK
{
KeepItOn = 1
SetTimer, CheckMouseMoved, Off
}
Return
^!z::
Gosub, AbortPrompt
SetTimer, CheckMouseMoved, 500
Gosub, TurnMonitorOff
Return
^+!z::
ExitApp