Reputation: 379
Using win32api.GetLastInputInfo() is an easy way to determine a USERS's idle time. However when running as a SERVICE this does not apply (always returns 0).
Does anyone know a simple way for a WINDOWS SERVICE to determine last keypress/mouse activity? (or some other effective way to determine idle time)
Upvotes: 2
Views: 1179
Reputation: 13645
Not in Python, but the approach proposed in http://www.codeproject.com/KB/DLL/trackuseridle.aspx looks interesting.
[edit]
The code it is a standard C DLL, so you should be able to use it with ctypes. The way the C code is written using SetWindowsHookEx
means you could maybe rewrite it directly Python + pywin32. See stackoverflow.com/questions/6458812 and python-forum.org/pythonforum/viewtopic.php?f=2&t=11154 for more on this (the first link mentions kinds of events you can get without writing a DLL, and the other shows a python example).
Upvotes: 1