Intercept Barcode Scanner, Pass to Application with Focus When Done?
c#, input, io, windows
Solution
To a computer, a barcode scanner is just like a keyboard, without the keys. When you scan a barcode, the scanner converts the barcode into keyboard input. In order to capture the input in a second program, you'd need to use a keyboard hook.
Look at this project and this project. You can make a program that uses one of these keyboard hooks and any data you scan with your barcode scanner will get routed to your program too.
Problem
Is there a way to intercept USB Barcode Scanner input, utilize it, then pass it on to the application that has focus? We currently use Barcode scanners load order shipment information into Endicia and FedEx. When those applications start up, the lookup field is given focus. When you scan a barcode, the text is passed into the field, and then those applications look up the rest of the customer information. This process works great. Now we are trying to limit pick errors by comparing the actual order weight with what it should be. In order to do this real-time, I need to intercept the scanner input and use it check the calculated weight in the database against the actual scale weight. If it is off by a significant margin I want to display a warning message. I also need to be able to then pass the barcode back to the correct field in the original application that had focus so it can look up the shipment data. Has anyone done something like this? Can you point me to some resources on intercepting input then bubbling it back up to the field that had focus? Note: This is in a Windows environment. I'm most familiar with C#, but VB.net would also work.