detecting idle time using python

后端 未结 5 1086
梦毁少年i
梦毁少年i 2020-12-24 07:28

How do I detect if the system is idle on Windows using Python (i.e. no keyboard or mouse activity). This has already been asked before, but there doesn\'t seem to be a

5条回答
  •  没有蜡笔的小新
    2020-12-24 08:06

    Actually, you can access GetLastInputInfo via the cytpes library:

    import ctypes
    GetLastInputInfo = ctypes.windll.User32.GetLastInputInfo  # callable function pointer
    

    This might not be what you want though, as it does not provide idle information across the whole system, but only about the session that called the function. See MSDN docs.

    Alternatively, you could check if the system is locked, or if the screen-saver has been started.

提交回复
热议问题