tags:

views:

266

answers:

3

Hey ;)

i want to do a application which works in background and read all keys pressed by user and save it in file. i start to write it in Win forms and use keys Pressed event but it works when form is focused:/

It is another way to do it? i hear about Windows Service, but i never use it :/

+2  A: 

You can do it with help of these:

I don't know your reasons, but I just hope they are "good".

Filip Ekberg
Maybe its stupid answer, but friend ask me for do that application and for me it it just a new programming adventure for learn something new. For now i refuse to him! What a fool i am :/ I am better spend time learning about WPF... sorry guys !
netmajor
A: 

I'm assuming you want to intercept all key events to all windows:

I wouldn't recommend C# for this. You'll need to drop to the Win32/64 API, which can be done, but you'd be better off using Visual C++ / something without training wheels.

There are several ways to do this. The easiest, by far, is to register a hook for keyboard events. Implement a basic service and handle the key-press events in your main loop / event handler. You can also just brute-force the keyboard state in a tight polling loop, but this will make the CPU cry.

There's 1,000,001 ways to install your own keyboard driver without admin privileges, but you're going to need to find one yourself, assuming you go down that road.

I seriously doubt that anyone on stackoverflow will help you create a key logger. You're going to need to dive into the bowels of the Win32 API and, likely, figure it out yourself. It isn't difficult if you have a solid C background. Windows "security" is little more than smoke & mirrors.

Pestilence
A: 

I came across this via google because im looking to write an app to pickup function keys (eg: F9) even though my program is in the background, so i can launch and kill applications (eg: windows media center, boxee) from my HTPC remote.

Just thought id say, as all background key capture programs arent suspicious!

Dos