PDA

View Full Version : C# .NET: Hijacking/controlling keyboard input



karl_eller
07-15-2008, 09:13 PM
I'm writing a program that uses a magnetic strip reader to scan credit cards and the like. The problem is that the swipe scanner we're using emulates a keyboard device, so if you have say Notepad open when you swipe a card through it, the output gets piped there.

What I'm wondering is if there is a way to get the program I'm writing to take control of that "keyboard" device so that any input from it ONLY goes to my program? Possibly without the program needing to have focus?

Eller

kromosto
07-23-2008, 04:24 AM
if it is not late this answer is hooking.

api functions are on the user32.dll

you can even get this functions to c# or write a c++ dll of your own that uses this api functions and you get your own dll functions to c#. second method is more flexiable but for what you want to do first method is enough. if you want example code i can provide you.