I need to be able to accept input from a barcode reader. The one my client needs to use behaves like a USB keyboard.
The problem is that I need to detect when it’s a barcode, and not just keyed in data.
Has anyone worked with a situation like this before?
Are there tricks to know the source of text input?
Is there some other way to hijack the input?
It’s definitely best to take Jiten’s advice, but if that isn’t possible then you could try a bit of a hack to detect the input from the scanner.
Barcode scanners as USB keyboards generally enter characters extremely quickly, much faster that anyone actually types unless they are just mashing keys on the keyboard.
So, you can measure the time between when each character is entered and then use some threshold to determine whether the characters are being entered quickly enough to qualify as a scan.
You would likely want to set up a single timer with a period of 100ms or so that resets every time a character is entered. When that timer’s action event fires, you know that the entry has stopped and can average the time between each character entry and take action based on that result (you would probably also want to set up a character limit that must be exceeded to qualify as a scan).
See (for example) this Honeywell (Pages 4-1 and below). Yours must have something similar.
MBS Plugin comes with some USB/HID support, which may work for some devices.
Or use serial port (possibly with adapter to USB).
Keyboard is bad, as problems with focus can cause trouble.
If you can get the barcode scanner as a serial device many problems just go away. I’d highly recommend this method.
I’m sold… Serial port it is.
I was hoping there was a typical way of forcing some kind of control character that no human would use. I can’t find a way.
[quote=387858:@Chris Halford]I’m sold… Serial port it is.
I was hoping there was a typical way of forcing some kind of control character that no human would use. I can’t find a way.[/quote]
Yeah. You add them to the barcodes themselves.
Do you have a link to the manual for the scanner? Most have the ability to do this.
I’ve solved this task myself.
While you can connect it to a serial port, you can also, as others mentioned, to reconfigure it to not act as a keyboard but issue them as a HID Scanner device. There’s a USB standard for this, and some scanner, e.g. GoDex, use that, making this rather easy. Then there’s the Datalogic and related scanner that do their own thing, but I’ve got a solution for that, too.
I’ve posted about this about 2 or 3 years ago here in the forum. You may also contact me directly if you want to go down this path instead of using a serial adapter.
You beat me to it - I was just about to post this link myself
I should mention that that old demo only deals with the official USB HID Scanner standard, but not with DataLogic & Co scanners which use different codes and for which docs are hard to come by. But as I wrote, I’ve solved this, too.
I’ll read tonight. Thanks guys!
OK, I don’t know if I can make this work.
I need to have it work on Mac and Windows.
The device reports itself as: “MJ_tech V3.08 2015/07/07” when I scan it’s “Display Version” barcode in the manual, but I can’t find the actual name anywhere to put into your code, Thomas.
I’m going to keep kicking this around for a few more hours before I get frustrated, but if you have any more tips to shove me in the right direction, I’d appreciate it.
I have use the first suggestion by Jiten above. Most barcode readers have the ability to add preambles and suffixes to the data values scanned. If you configure the hardware to add a character you can check for the character and determine the source. This will work in Windows and OS X.
You can even make the suffix a control character and intercept it as the field terminator with a little Xojo code to detect an individual character.
If you don’t use a control character a simple text character that will never appear in key input data can be added in the front or back of the string.
Mark, I’ve tried this.
I’m trying to “intercept” in an HTMLViewer control, but I never get the events.
I’m guessing without the cursor in a field where it’d be received, the events don’t fire.
I even tried putting a transparent canvas on top to capture key events, but nothing is firing.
and I see another thread discussing this.
I don’t think anybody is getting keydown events with the HTMLViewer on the Mac
do you have a programming sheet for the scanner, in which there’s a code for switching it into a HID or “POS” command mode?
You need to put it into that mode first.
You might find some docs if you google “symcmjde barcode scanner manual” - though the manufacturer’s site, which appears to be symcode.net, seems to be down (I only get empty pages). There are other sites with some pdfs for it, though.
No I don’t Thomas. I think this Barcode scanner may not be the best choice.