I previously assumed Windows was getting confused. I made a program to log key ups and downs and realized quickly that STX (0x02) was being translated to: I hoped that I could detect this pattern reliably and intercept the keystrokes. I dug a bit deeper beyond the first character and noticed a pattern. :( Retryīack to WPF and a simple PreviewKeyUp. But then I ran my first test and got a code of 162. I succeeeded wtih one test and became excited. Most had problems with WPF and required a lot of adaptation because they were written for WinForms and relied on Windows messages. I gave up this approach and tried many of the more complex WinAPI approaches to try to access the raw input from the bar code scanner. Not all ASCII codes can map to scan codes. Part of this complication is because WPF generally deals with scan codes and not ASCII codes.
LeftCtrl? Obviously WPF didn't know how to handle low ASCII codes that keyboards were never designed to send. I created a KeyDown event in a WPF app and scanned a bar code.
For widest compatibilty STX (start of text, 0x02 ASCII) and ETX (end of text, 0x03 ASCII) are the best choices. Many scanners allow you to program them with a verity of characters. First Attemptīar code scanners can be programmed to send a prefix and suffix for each scan. This method also required the developer to uniquely identify they device specifically on each machine. These solutions required a lot of external calls and many relied on Windows messages which did not work as well with WPF. In the end we later swtiched to raw support for the thermal printers as well and completely eliminated OPOS and all its hassles with it.Īfter more research I learned that many users resorted to the WinAPI and keyboard hooks. Bar code scanners however are lower cost items and in a given site ther eare often many different brands of scanners.
Vendor support for OPOS is varied, and very often the vendor drivers are shoddy and not well supported. OPOS however relies on individual setup on each machine, and a separate OPOS driver for each piece of hardware. In the past we had used OPOS in the past for interacting with high speed thermal printers. But this seemed like a lot of fuss just to be able to get data from the bar code scanner and know it came from the bar code scanner. There are ways to directly integrate with bar code scanners using third party libraries, SDKs, or OPOS. This approach permits a lot of user mistakes. The application just took the text sent to it and was oblivious as to wheter it came from the keyboard or a bar code scanner.
The software did not know the difference between the scanner and the keyboard. But users were required to tell the software first by clicking a button, or selecting a text box first and then scanning the code.
Previously we had used bar code scanners for lookups, serial number entry, etc.
Recently we needed to integrate bar code readers. One of my projects required integration with POS peripherals for sales, receiving, inventory, and other standard retail functions. This allows the user to scan bar codes without needing to put the focus on a special field, or activate buttons or menu items before each scan.
Many of the generic or clone scanners which are now a common commodity have no API and rely solely on keyboard emulation which further complicates the issue.įortunately, there is an easy yet not well known method for detecting distinct input from the bar code scanner. In the real world, there are thousands of bar code scanners and relying on vendor specific APIs is not practical. Many vendors have their own APIs which can be used to distinguish the bar code scanner from the keyboard.
This method does not allow the application to take instant action when a scan is received because the application has no way of distinguishing the bar code scanner input from the keyboard. This same behaviour also allows the user to scan bar codes into fields not intended for scanning and can cause problem. The user simply needs to put the focus on any text input control and then scan a bar code. This allows them to be easily used in any application. Most bar code scanners emulate keyboards.