Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I detect if a user is away from keyboard? [duplicate]

Tags:

c#

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?

like image 215
Styler2go Avatar asked Oct 31 '12 17:10

Styler2go


1 Answers

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.

like image 174
Paul Sasik Avatar answered Sep 30 '22 20:09

Paul Sasik