I am trying to work out how long, approximately, the current user has been idle (e.g. like this question), from Python on a Windows machine.
To do that, I figure I need to compare the result of GetLastInputInfo with the result of GetTickCount. The results should be in milliseconds.
(I am expecting roll-over problems every 49.7 days, but I will solve that later.)
My code is straightforward:
import win32api
last_active = win32api.GetLastInputInfo()
now = win32api.GetTickCount()
elapsed_milliseconds = (now - last_active)
print(last_active, now, elapsed_milliseconds)
I expect to get two similar large numbers, and a difference of a few hundred milliseconds.
Instead, I get results like:
3978299058 -316668238 -4294967296
and
3978316717 -316650501 -4294967218
Between runs, they are both changing by roughly the same amount, but there is a large constant offset between them that I am not expecting.
What am I missing?