Possible Duplicate:
Detecting that the user is away from the PC with .NET
I want to make a function which determines if someone is currently AFK or not. For that I want to listen to the Keyboard Keys. Any ideas how to realize such a function?
The normal KeyPressed
event works only if the Form is focused, right?
That's right. You need something more global since a user will not have focus set onto a single application. Take a look at this CodeProject article/Codeplex project
Regardless of language and framework this is how applications such as instant messengers determine whether or not a user is AFK. It should be noted though that this can be used for nefarious purposes such as key loggers.
Abstract:
This class allows you to tap keyboard and mouse and/or to detect their activity even when an application runs in the background or does not have any user interface at all. This class raises common .NET events with KeyEventArgs and MouseEventArgs, so you can easily retrieve any information you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With