Reafidy
Reafidy

Reputation: 8441

Get application input idle time

I would like to get the idle time of my Windows Forms application (not the system). This will enable me to update the database to show which users are online/offline amongst other things.

I have searched extensively here, googled, and have come up empty handed.

Upvotes: 0

Views: 847

Answers (1)

pabdulin
pabdulin

Reputation: 35225

The way to me is to monitor for mouse and keyboard events and update some static variable, see. I'm not sure if you need to go so deep to Win32 calls, maybe you'll be just fine with standard .NET events.

As Hans Passant noted you can use Application.Idle static event. However be sure to deattach it in Application.Exit event, to avoid memory leaks.

P.S. for C# to VB.NET translation you can use this.

Upvotes: 1

Related Questions