Keyboard hook return different symbols from card reader depends whther my app in focus or not

Posted by user363868 on Stack Overflow See other posts from Stack Overflow or by user363868
Published on 2010-06-11T16:59:06Z Indexed on 2010/06/11 17:03 UTC
Read the original article Hit count: 395

Filed under:
|
|
|

I code WinForm application where one of the input is magnetic stripe card reader (CR). I am using code George Mamaladze's article Processing Global Mouse and Keyboard Hooks in C# on codeproject.com to listen keyboard (USB card reader acts same way as keyboard) and I have weird situation.

One card reader CR1 (Unitech MS240-2UG) produces keystroke which I intercept on KeyPress event analyze that I intercept certain patter like %ABCD-6EFJHI? and trigger some logic. Analysis required because user can type something else into application or in another application meanwhile my app is open

When I use another card reader CR2 (IdTech IDBM-334133) keystroke intercepted by hook started from number 5 instead of % (It is actually same key on keyboard). Since it is starting sentinel it is very important for me to have ability recognize input from card reader. Moreover if my app running in background and I have focus on Notepad when I swipe card string %ABCD-6EFJHI? appears in Notepad and same way, with proper starting character) intercepted by keyboard hook. If swiped when focus on Form it is 5ABCD-6EFJHI?

User who tried app with another card reader has same result as me with CR2. Only CR1 works for me as expected

I was looking into Device manager of Windows and both devices use same HID driver supplied by MS. I checked devices though respective software from CR makers and starting and ending sentinels set to % and ? respective on both.

I would appreciate and ideas and thoughts as I hit the wall myself

Thank you

© Stack Overflow or respective owner

Related posts about keyboard

Related posts about hook