The following script will turn off the screen at 10 secs of being idle, not 9, not 11. The script will check the value of A_TimeIdlePhysical, and will wait the remaining time to get the value entered at the variable IdleTimeSet.
Once the 10 secs are passed without moving the mouse or pressing a key, it will show a message telling you it will turn off the screen in 2 seconds, to abort it, simply move the mouse or press a key.
I wrote it to use it when listening music. Hope you like
Code:
;lnminente 2012 01 31
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
;Menu, Tray, Icon, D:\Documents\Pictures\monitor-off-icon.ico
IdleTimeSet := 10000 ; 10 segundos para apagar la pantalla
Loop{
IF abs( IdleTimeSet - A_TimeIdlePhysical ) < 100 ;Tolerancia de +-100ms
{
UntilIdle := IdleTimeSet
splashTextOn, , , En 2 segundos se apagara la pantalla
Sleep 2000
IF A_TimeIdlePhysical > 2000
{
SendMessage, 0x112, 0xF170, 2,, Program Manager ; 0x112 is WM_SYSCOMMAND, 0xF170 is SC_MONITORPOWER.
}
else
{
UntilIdle := IdleTimeSet - A_TimeIdlePhysical
}
splashTextOff
}
else
{
IF IdleTimeSet - A_TimeIdlePhysical > 0
UntilIdle := IdleTimeSet - A_TimeIdlePhysical
}
;splashTextOn, , , Until: %UntilIdle% Idle:%A_TimeIdlePhysical%
Sleep UntilIdle
}
return