System Idletime

Hello all,

i just want to get the users idletime, meaning how much time passed after the last user input on the system.
I found some "solutions", but something like GetLastInput() does not work for me.

Can somebody give me an advice how to implement that into a little function?

With kind regards,

The simplest is to store the time when the app's message loop processes an event, and compare the elapsed time when the next app event occurs.

A more complicated solution could be:
HOWTO track a user's idle time - CodeProject

BTW, why did you mark this topic as solved? Did you figure out how to do the task yourself already? If'n you did it sure would be nice if you would mention it.

Call this function in a loop, with a certain delay (e.g. 1000 ms), and calculate the difference in lpIdleTime, lpKernelTime, and lpUserTime between each pair of successive calls. This will tell you how much time the system has spent in each "state" (i.e. "idle", "kernel" or "user") — during the last time interval.

(Be aware that the value lpKernelTime also includes the value of lpIdleTime, so you will have to subtract lpIdleTime from the lpKernelTime, in order to get the "pure" kernel time value)
Last edited on
Thank you guys :)
I do not know how, where, etc. But somewhere, windows tracks the idle time and uses that to fire up screen savers, lock the screen, etc. I know its out there, and I am pretty sure you can just ask for it, but again, I don't know where or how.
All the online examples show a ream of code to get it done using timers or whatever, so maybe I am just having a wistful thinking moment, but a bit of investigation for a better mousetrap may be in order (and forgive the bad pun).

edit: it could be tied to making use of "GetLastInputInfo"
Last edited on
Topic archived. No new replies allowed.