Reputation: 1794
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
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
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