Alex Rivera | Logout

C# - Detect time of last user interaction with the OS

Asked 2009-06-24T10:42:35.217
85

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?

Edit
Report

1 Answer

77

GetLastInputInfo. Documented at PInvoke.net.

answered 2009-06-24T10:55:07.653

Your Answer