Capturing all keyboard events using VB.Net

I wrote an application with a simple text field that tries to identify the user from their typing habits (the interval between keystrokes, the duration key is held, the time between keystrokes, i.e. a-> s is faster than a-> v for some users, shorter for others, depending on input style). This is far from ideal, but it correctly identifies moderately large differences in style.

I hope to use this as a form of security monitor. If the user input style does not match the recognized template, send the report to the central server.

Of course, the next step in testing is to start fixing the “regular” typing habits - that is, when viewing, switching between applications, etc.

What I cannot figure out how to do is capture keyboard input for all applications (excluding the login / welcome screen, alternate desktops, etc.). I have no reason to parse this, and probably)

Disclaimer: Yes, I know that it is dangerously close to writing a keylogger, which is verboten, but if I wanted to do this, I would write a keyboard driver in C ++ - I'm sure it will be much more simplified and easier confused than a clumsy .Net MSIL assembly. I have no doubt that I will deflect the comments “This is a keylogger”, but I hit the wall and I have to ask somewhere ...

I do not need the application to be hidden, but ideally I would like to record the input without explicit user confirmation (outside of the installation by the administrator). If user confirmation is required, I can live with it (simply) if it can be one-time, and I have a way to track and report a failure.

Is this possible in .Net? The only examples I could find either work by adding an event hook to each key that seems clumsy, and I would suggest that it is error prone. -or- They polled the status of the keyboard to determine the keys pressed. This is not good for me, since a) I need precise keystroke timings, so up / down key events are mandatory and b) this is unpleasant.

, , , , . .

.

: Hans Passant , , : http://www.codeguru.com/columns/vb/article.php/c4831

+5
2

Google SetWindowsHookEx + WH_KEYBOARD_LL, , Google. . , VB.NET.

+5

.net , p/invoke. :

  • Win hooks
  • GetAsyncKeyState
0

All Articles