I'm making a script that gets the idle duration based on the last mouse or keyboard input time. The following piece of code worked on Windows but I need one which would run on Linux.
class LASTINPUTINFO(Structure):
_fields_ = [
('cbSize', c_uint),
('dwTime', c_uint),
]
def get_idle_duration():
# get idle time
lastInputInfo = LASTINPUTINFO()
lastInputInfo.cbSize = sizeof(lastInputInfo)
windll.user32.GetLastInputInfo(byref(lastInputInfo))
millis = windll.kernel32.GetTickCount() - lastInputInfo.dwTime
return millis / 1000.0
print(get_idle_duration())
Can someone help me run this on both Windows and Linux?