DVD
DVD

Reputation: 1794

Getting all the pressed keys everywhere

So is there possible to intersect all keys pressed everywhere, where everywhere is at any application? More or so like a keylogger. I was wondering if that is possible in C++ or C#.

Regards

Upvotes: 2

Views: 1878

Answers (2)

j_kubik
j_kubik

Reputation: 6181

If you want to use winapi thaen function you are looking for is SetWindowsHookEx with flag WH_KEYBOARD. If you want to get really all kes you might use low-lewel flag instead WH_KEYBOARD_LL, but this will not translate keystrokes, so it's more difficult to work with.

I never used this flag, but i know that some flags need registered hook function to be in separate module (eg. dll) as they will be loaded and executed executed in context of application that actually recieves keyboard input. If it is so you must also think of a mechanism of returning colected data back to your application, cause global variables will not work.

Upvotes: 0

BFree
BFree

Reputation: 103770

What you're looking for is a Keyboard Hook. This is possible using some P/Invoke. See sample here:

http://www.codeproject.com/KB/cs/CSLLKeyboardHook.aspx

Upvotes: 2

Related Questions