Horst Herb <subscriptions <at> gnumed.net> writes:
> I don't know if this will work, but, in theory, an idle event is emitted
> whenever the event cue becomes empty. This can only happen if there are
> events, which indicate the user is interacting with the app. If you set
> a timer in the idle event , and re-set it each time you get an idle
> event, then when it goes off, it should indicate inactivity.
>
> The first complication I see is that a timer event is an event, and so
> may set off an idle event.....
If the timer event sets a flag, and the idle event checks whether the timer
event flag is set, and if so, checks how much time elapsed since the flag was
set, and unsets the flag if not enough time elapsed ...
Horst
if you want to do this on windows (xp in particular) and you want to detect if
the user has made no input on any input device to any application, the way msn
messenger detects if you've been "away", then you'll need win32all and ctypes
and then you can do this:
import win32gui
from ctypes import *
GetTickCount = windll.kernel32.GetTickCount
GetLastInputInfo = windll.user32.GetLastInputInfo
class LASTINPUTINFO(Structure):
_fields_ = [("cbSize", c_uint), ("dwTime", c_uint)]
lastInputInfo = LASTINPUTINFO()
lastInputInfo.cbSize = sizeof(lastInputInfo)
def getLastInpuTime():
GetLastInputInfo(byref(lastInputInfo))
return float(GetTickCount()-lastInputInfo.dwTime)/1000
if __name__ == '__main__':
import time
while True:
print "Last input time:", getLastInputTime()
time.sleep(1)
run it and wait a while before typing or moving the mouse, it returns the number
of seconds since the last input on any input device. if you only need to detect
idle time for your app, then do it as specified in the previous message.
/r
···
On Thursday 27 April 2006 08:40, Christopher Barker wrote: