Is there an event after Barcode Scan is Finished?
I have a simple USB barcode reader which I intend to use to scan COD 39 barcodes. I know that just scanning the barcode while having a text field on focus will get me the text input of the barcode I'm scanning. However my requirement is a bit different.
I need to create a C# application where upon reading a barcode it will check the read barcode with a list I have to see whether it exists. The problem is I cannot keep a text box on my app in focus all the time as the app does other things as well. Instead what I want is for my program to keep looking for some sort of "event" which will be raised once the bar code scanners scans a code.
So does anyone know if there is such an event which will be raised when the barcode is scanned some code so I can instruct my program to do the rest of the work when the scanners scans a barcode?
sachintha81
Junior Poster in Training
96 posts since Apr 2008
Reputation Points: 35
Solved Threads: 1
Thanks Ketsuekiame for reply.
Yes it is a keyboard emulation scanner and is listed under "Keyboards" in device manager. I bought it from Amazon Japan (yes I live there) and is a pretty cheap one so doesn't have much documentation except for a very vague User Manual.
Alright then I will take a look at the PreviewKeyDown event.
sachintha81
Junior Poster in Training
96 posts since Apr 2008
Reputation Points: 35
Solved Threads: 1
A lot of them do send "\r\n" after a scan by default, but this depends on how you set the scanner up and the scanner itself. The OP needs to read the instructions and documentation for the scanner. The USB scanners I use here can be configured with multiple or no key-presses after a successful scan.
But this isn't an "event" Per-Se. The OP will need to have their code monitoring the scanner input and as it comes from a keyboard emulator, there's no way to differentiate it from a normal keyboard input.
In my opinion, the OP was already using the best method by having the input go into a text box. This also allows you a fall back in case the scanner itself doesn't work or the barcode is malformed (due to damage or obstruction) it would allow the operator to type in the barcode number (provided it wasn't a 2D code)
Yes it does send a "Return" at the end. I also found out that it is possible to configure the scanner so that it will add a either or both a prefix as well as suffix to the code before displaying on the computer so I guess I can use that to safeguard against unintentional key presses.
Thanks mate for the help!
sachintha81
Junior Poster in Training
96 posts since Apr 2008
Reputation Points: 35
Solved Threads: 1