A customer asked me: “ can you make a …simple… program that reads from a barcode reader attached to a usb port.
I have no idea where to begin. Maybe one of you have some ideas
summary: Yes it’s possible, no it’s not hard.
There are 2 “kinds” of barcode reader. (These days some can be set to whichever kind you prefer, otherwise buy the right one.)
a) Keyboard Wedge kind. This is really just a “keyboard” from Window’s point of view. Whatever the reader spits out ends up in the keyboard buffer. Nothing for you to do really it “just works”. However it works exactly like the keyboard - whatever program or field has the focus, that’s where the number ends up.
b) “Serial Port” kind. So called because it exposes itself to Windows as a serial port device. So the input from that is trapped separately to the program or field that has the focus. Basically your program (window) “opens” the port, listens, and does whatever it likes with the input.
For Serial port readers you can access the port directly using the Windows API, or use a Clarion Library to do the hard work for you (like WinEvent - https://www.capesoft.com/docs/winevent5/WinEvent.htm#UserCommsFunctions).
The big advantage of this approach is that your program gets the input regardless of what other program, or window in your program, has the focus. So ideal for more robust solutions - or where the user can’t see the PC screen.