views:

50

answers:

1

I'd like to have an AutoIt script log the idle time. Alternatively, I'd like to be able to detect when the screensaver is active. There is no function that gives me either of these. How would I go about getting this functionality?

+1  A: 

Eh. Found it on a forum.

#include <Timers.au3>

Global $iLimit = 5 ; idle limit in seconds

HotKeySet("{ESC}", "_Quit")

AdlibRegister("_CheckIdleTime", 500)

While 1
    Sleep(20)
WEnd

Func _CheckIdleTime()
    If _Timer_GetIdleTime() > $iLimit * 1000 Then MsgBox(16, "Timeout", "You haven't done anything in " & $iLimit & " seconds...  Get busy!", 3)
EndFunc   ;==>_CheckIdleTime

Func _Quit()
    Exit
EndFunc   ;==>_Quit
Stride
@Stride: The _Timer_GetIdleTime() function uses GetLastInputInfo from user32.dll. This was a bit of a pain for me to figure out before the Timers.au3 was created. I didn't know this was now a standard part of the library. Thanks for the answer good job.
Copas