Click here to Skip to main content
15,908,015 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Folks,

I need to integrate a barcode scanner that acts like a USB keyboard with out application. Our application has an existing low level keyboard hook that is created as follows
::SetWindowsHookEx( WH_KEYBOARD_LL, LLKeyboardHook, hModule , 0);

The problem here is that this low-level keyboard hook is unable to capture the key presses emulated by the barcode scanner. If I create the hook using the "WH_KEYBOARD" hook type , then I am able to get the correct input from the barcode scanner. But due to certain constraints, I wouldnt be able to use a hook of this type.

Is this the correct way to trap the input from a barcode scanner? Should anything more be done? I was hoping that since the barcode scanner would act like a keyboard, it should get trapped in the existing keyboard hook.

Anyone faced this problem before? Any thoughts or sample code is highly appreciated.

Thanks in advance.
Posted

1 solution

Skip the keyboard hook and use an API like OPOS or NPOS[^]

OPOS is really easy to use, probably significantly easier than your current approach.


Or take a look at Barcode scanning[^] - look at revision 1 for a more complete version of the code. Allows you to easlily read barcodes from a Symbol barcode scanner connected to the serial port. All you need is to implment a single event handler.

Regards
Espen Harlinn
 
Share this answer
 
Comments
Hellraiser123 1-Feb-11 11:46am    
Am using a USB barcode scanner and am writing code in VC++ . So am not sure both the links above help much. But thanks anyway. Do you see anything else that might cause this behavior?
Espen Harlinn 1-Feb-11 14:12pm    
OPOS works like a charm with USB, and I've tested the serial code against USB port configured in BIOS as a serial port using an USB scanner.

OPOS can easily be used from VC++, Delphi, VB.Net, C# and just about any development environment supporting COM - even javascript in the IE browser will work as long as an OPOS compliant driver is installed on the client computer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900