views:

453

answers:

1

I'm writing a small tray application that needs to detect the last time a user interacted with their machine to determine if they're idle.

Is there any way to retrieve the time a user last moved their mouse, hit a key or interacted in any way with their machine?

I figure Windows obviously tracks this to determine when to display a screen saver or power down, etc, so I'm assuming there's a Windows API for retrieving this myself?

+7  A: 

GetLastInputInfo. Documented at PInvoke.net.

Matthew Flaschen
Perfect, thank you.
GenericTypeTea
+1 for PInvoke.net - I didn't know about that resource until now.
John K