[python-win32] Windows "idle" time & killing a process
timr at probo.com
Fri Dec 11 19:39:09 CET 2009
Randy Syring wrote:
> I use synergy to connect the keyboard and mouse on my desktop to my
> laptop. However, I have found that synergy keeps my monitors from
> shutting off when it is running. I often forget to turn synergy off
> at the end of the day, which means my monitors waste energy and bulb
> I would like to write a script in Python that would check if the
> computer had been idle (i.e. no user input) for > 1 hour and if so,
> shut down synergy if it is running. I would appreciate pointers in
> two areas:
> * How would I check how long the computer had been idle
> * How would I kill a process if I only know the name
> Brief references would be fine, I am happy to go digging.
Idle time detection in Windows is surprisingly tricky. You can have a
message sent to you when the screensaver fires up, but Synergy might be
suppressing that as well. You could change your power management setup
to suspend or hibernate after an hour or two of idle time.
The only sure-fire method that I'm aware of is to install mouse and
keyboard hooks and watch the activity yourself. That cannot (today) be
done in Python.
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the python-win32