03-02-2012 12:52 PM
I have a string input that I want a user to enter a string upto 20 characters or to read in from a barcode reader.
After the operator presses enter or after the barcode reader data is entered I want to set the focus on another control. For the operator enter mode I capture the event using the EVENT_COMMIT event and there is no problem. However I also want to be able to determine where the entry is from the barcode reader of the keyboard, and after scanning in from a bar code reader to automatically set the focus on a new control without the operator pressing the enter key. Is there a way to do this?
03-02-2012 03:00 PM
I worked on this problem before and could not find an elegant solution. The real issue is that your HID drivers for most barcode scanners is designed to look exactly like a keyboard and does not distinguish its data from real keyboard data in any way. Thus Windows does not know the difference between a barcode scanner and a real keyboard.
One complicated method would be to write your own driver for the scanner that implements a method of differentiating it from a keyboard. This however might require information about the scanner that is not exposed in the manual (reverse engineering time?) http://digital.ni.com/public.nsf/allkb/E3A2C4FE42D7ED0D86256DB7005C65C9?OpenDocument
A common workaround for this is to use characteristics of the input to distinguish it from keyboard input. For example, the barcode scanner will input an 8 digit number in less than 50ms, while a user on a keyboard would never be able to input 8 numbers that fast. Additionally, barcode scanners will typically terminate with a ENTER key.
This is a common question that you may find good ideas on other forums for (stack overflow). I used the timing of the input when I did this and it worked well enough. I would post my code for that, but it was in LabVIEW and I deleted it long ago.