Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monitoring keyboard activity in C# while my application is in the background

First of all I need to make it clear that I have no interest in keylogging.

I need a way to monitor keyboard activity at the most basic level while my application is in the background. I don't need to know which keys, I don't need to save any data, I don't need or plan to hide my application at all, all I need is to know when keys are pressed and invoke a method.

I'm looking for the simplest way to do this possible, I know a reasonable amount of C# but nothing too complex as most of my knowledge is self-taught.

I've looked around for some appropriate ways of doing this and I've found nothing useful. All I've found is a bunch of people saying "No, that's illegal" on forums and source code for in depth keyloggers.

If any of you could advise me on a way to achieve this then I would be most appreciative.

like image 628
Tane Lattanzio Avatar asked Apr 30 '12 12:04

Tane Lattanzio


1 Answers

You'll need to use Window Hooks:

Low-Level Keyboard Hook in C#

But beware, Windows security, may be protecting us from doing what you want!

like image 62
Mesh Avatar answered Oct 22 '22 01:10

Mesh