Say oooooooooh, you don't want to measure idle time in your program, you want to measure idle time in Windows.

Well, that's easy with the mouse. Just use getcursor pos to find the coordinates of the mouse, and keep checking to see if it's in the same place. That would probably be a lot easier for you than checking to see if a button is pressed.

As far as the keyboard goes, it gets a lot more complicated, because basically you'd have to go through every possible key and check each one to see if any are pressed. See what I'm saying?