How can I determine the display idle time from Python in Windows, Linux, and MacOS?

前端 未结 3 1695
别跟我提以往
别跟我提以往 2020-12-23 23:05

I would like to know how long it\'s been since the user last hit a key or moved the mouse - not just in my application, but on the whole \"computer\" (i.e. display), in orde

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-23 23:17

    I got an answer regarding mouse-clicks suggesting to use pyHook:

    Detecting Mouse clicks in windows using python

    Here's some other code I did to detect mouse-position via ctypes: http://monkut.webfactional.com/blog/archive/2008/10/2/python-win-mouse-position

    A more round-about method to accomplish this would be via screen capture and comparing any change in images using PIL.

    http://www.wellho.net/forum/Programming-in-Python-and-Ruby/Python-Imaging-Library-PIL.html

提交回复
热议问题