# Barcode Reader

**URL:** <https://forum.xojo.com/t/barcode-reader/43509>\
**Category:** General\
**Created:** [May 15, 2018, 2:14pm UTC](https://forum.xojo.com/t/barcode-reader/43509 "2018-05-15T14:14:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Halford](https://forum.xojo.com/user_avatar/forum.xojo.com/chris_halford/32/480_2.png) [@Chris\_Halford](https://forum.xojo.com/u/Chris_Halford)\
**Post date:** [May 15, 2018, 2:14pm UTC](https://forum.xojo.com/t/barcode-reader/43509/1 "2018-05-15T14:14:17Z")

</div>

Hey folks,

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?

---

<div class="post-metadata">

**Author:** ![Jiten\_Shah](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/6bbea6/32.png) [@Jiten\_Shah](https://forum.xojo.com/u/Jiten_Shah)\
**Post date:** [May 15, 2018, 2:27pm UTC](https://forum.xojo.com/t/barcode-reader/43509/2 "2018-05-15T14:27:43Z")

</div>

There is two way

1. Configure barcode scanner to send special character with barcode

2. use barcode scanner as serial device

---

<div class="post-metadata">

**Author:** ![Jared\_Feder](https://forum.xojo.com/user_avatar/forum.xojo.com/jared_feder/32/3036_2.png) [@Jared\_Feder](https://forum.xojo.com/u/Jared_Feder)\
**Post date:** [May 15, 2018, 2:44pm UTC](https://forum.xojo.com/t/barcode-reader/43509/3 "2018-05-15T14:44:48Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![José\_María\_Terry\_Jiménez](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/fbc32d/32.png) [@José\_María\_Terry\_Jiménez](https://forum.xojo.com/u/Jos%C3%A9_Mar%C3%ADa_Terry_Jim%C3%A9nez)\
**Post date:** [May 15, 2018, 2:47pm UTC](https://forum.xojo.com/t/barcode-reader/43509/4 "2018-05-15T14:47:18Z")

</div>

See (for example) this Honeywell (Pages 4-1 and below). Yours must have something similar.

[http://www.htz.com.tw/products/1250G/manual/VG1250-UG%20Rev%20D.pdf](http://www.htz.com.tw/products/1250G/manual/VG1250-UG%20Rev%20D.pdf)

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [May 15, 2018, 2:54pm UTC](https://forum.xojo.com/t/barcode-reader/43509/5 "2018-05-15T14:54:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Bob\_Keeney](https://forum.xojo.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@Bob\_Keeney](https://forum.xojo.com/u/Bob_Keeney)\
**Post date:** [May 15, 2018, 3:05pm UTC](https://forum.xojo.com/t/barcode-reader/43509/6 "2018-05-15T15:05:53Z")

</div>

If you can get the barcode scanner as a serial device many problems just go away. I’d _highly_ recommend this method.

---

<div class="post-metadata">

**Author:** ![Chris\_Halford](https://forum.xojo.com/user_avatar/forum.xojo.com/chris_halford/32/480_2.png) [@Chris\_Halford](https://forum.xojo.com/u/Chris_Halford)\
**Post date:** [May 15, 2018, 3:25pm UTC](https://forum.xojo.com/t/barcode-reader/43509/7 "2018-05-15T15:25:28Z")

</div>

I’m sold… Serial port it is.  
Thanks!

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.

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [May 15, 2018, 8:43pm UTC](https://forum.xojo.com/t/barcode-reader/43509/8 "2018-05-15T20:43:36Z")

</div>

[quote=387858:@Chris Halford]I’m sold… Serial port it is.  
Thanks!

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.

---

<div class="post-metadata">

**Author:** ![anon20074439](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@anon20074439](https://forum.xojo.com/u/anon20074439)\
**Post date:** [May 15, 2018, 9:06pm UTC](https://forum.xojo.com/t/barcode-reader/43509/9 "2018-05-15T21:06:16Z")

</div>

> [@387858:@Chris Halford](#):
>
> I was hoping there was a typical way of forcing some kind of control character that no human would use.

Do you have a link to the manual for the scanner? Most have the ability to do this.

---

<div class="post-metadata">

**Author:** ![Thomas\_Tempelmann](https://forum.xojo.com/user_avatar/forum.xojo.com/thomas_tempelmann/32/315_2.png) [@Thomas\_Tempelmann](https://forum.xojo.com/u/Thomas_Tempelmann)\
**Post date:** [May 16, 2018, 8:58pm UTC](https://forum.xojo.com/t/barcode-reader/43509/10 "2018-05-16T20:58:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Markus\_Winter](https://forum.xojo.com/user_avatar/forum.xojo.com/markus_winter/32/144_2.png) [@Markus\_Winter](https://forum.xojo.com/u/Markus_Winter)\
**Post date:** [May 16, 2018, 9:01pm UTC](https://forum.xojo.com/t/barcode-reader/43509/11 "2018-05-16T21:01:56Z")

</div>

> [@388137:@Thomas Tempelmann](#):
>
> I’ve posted about this about 2 or 3 years ago here in the forum.

[https://forum.xojo.com/24557-bar-code-scanning-solution-for-os-x/0](https://forum.xojo.com/24557-bar-code-scanning-solution-for-os-x/0)

---

<div class="post-metadata">

**Author:** ![Thomas\_Tempelmann](https://forum.xojo.com/user_avatar/forum.xojo.com/thomas_tempelmann/32/315_2.png) [@Thomas\_Tempelmann](https://forum.xojo.com/u/Thomas_Tempelmann)\
**Post date:** [May 16, 2018, 9:03pm UTC](https://forum.xojo.com/t/barcode-reader/43509/12 "2018-05-16T21:03:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Chris\_Halford](https://forum.xojo.com/user_avatar/forum.xojo.com/chris_halford/32/480_2.png) [@Chris\_Halford](https://forum.xojo.com/u/Chris_Halford)\
**Post date:** [May 16, 2018, 11:59pm UTC](https://forum.xojo.com/t/barcode-reader/43509/13 "2018-05-16T23:59:00Z")

</div>

Ahhhh hope.  
I’ll read tonight. Thanks guys!

---

<div class="post-metadata">

**Author:** ![Chris\_Halford](https://forum.xojo.com/user_avatar/forum.xojo.com/chris_halford/32/480_2.png) [@Chris\_Halford](https://forum.xojo.com/u/Chris_Halford)\
**Post date:** [May 17, 2018, 12:31am UTC](https://forum.xojo.com/t/barcode-reader/43509/14 "2018-05-17T00:31:07Z")

</div>

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.

Thanks.

---

<div class="post-metadata">

**Author:** ![Mark\_Strickland](https://forum.xojo.com/user_avatar/forum.xojo.com/mark_strickland/32/628_2.png) [@Mark\_Strickland](https://forum.xojo.com/u/Mark_Strickland)\
**Post date:** [May 17, 2018, 12:40am UTC](https://forum.xojo.com/t/barcode-reader/43509/15 "2018-05-17T00:40:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Chris\_Halford](https://forum.xojo.com/user_avatar/forum.xojo.com/chris_halford/32/480_2.png) [@Chris\_Halford](https://forum.xojo.com/u/Chris_Halford)\
**Post date:** [May 17, 2018, 12:42am UTC](https://forum.xojo.com/t/barcode-reader/43509/16 "2018-05-17T00:42:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Chris\_Halford](https://forum.xojo.com/user_avatar/forum.xojo.com/chris_halford/32/480_2.png) [@Chris\_Halford](https://forum.xojo.com/u/Chris_Halford)\
**Post date:** [May 17, 2018, 1:12am UTC](https://forum.xojo.com/t/barcode-reader/43509/17 "2018-05-17T01:12:06Z")

</div>

and I see another thread discussing this.  
I don’t think anybody is getting keydown events with the HTMLViewer on the Mac ☹

---

<div class="post-metadata">

**Author:** ![Thomas\_Tempelmann](https://forum.xojo.com/user_avatar/forum.xojo.com/thomas_tempelmann/32/315_2.png) [@Thomas\_Tempelmann](https://forum.xojo.com/u/Thomas_Tempelmann)\
**Post date:** [May 17, 2018, 7:26am UTC](https://forum.xojo.com/t/barcode-reader/43509/18 "2018-05-17T07:26:03Z")

</div>

Chris,  
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](http://symcode.net), seems to be down (I only get empty pages). There are other sites with some pdfs for it, though.

---

<div class="post-metadata">

**Author:** ![Chris\_Halford](https://forum.xojo.com/user_avatar/forum.xojo.com/chris_halford/32/480_2.png) [@Chris\_Halford](https://forum.xojo.com/u/Chris_Halford)\
**Post date:** [May 18, 2018, 12:18am UTC](https://forum.xojo.com/t/barcode-reader/43509/19 "2018-05-18T00:18:54Z")

</div>

No I don’t Thomas. I think this Barcode scanner may not be the best choice.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 7:12pm UTC](https://forum.xojo.com/t/barcode-reader/43509/20 "2020-10-29T19:12:57Z")

</div>


