I want to understand how to create/extend a badge scanner listener from a device that reads like a USB Keyboard Wedge.
Since 2005, I’ve used a WinForms app, combined with a programmed barcode scanner, to listen for the key I programmed into the USB barcode scanners that read like a keyboard wedges.
In my WinForms App, I was able to solve this by programming the scanner to “bookend” scans with certain characters, and checking the (int)KeyChar value from my Controller’s KeyPress event’s KeyPressEventArgs. If it gets the programmed starting char, it listens for X seconds for the ending char. If received, it parses the data. If not, it sends notification that the scan was problematic.
In a nutshell, this app really does nothing more than:
- Listens for & parses the badge scan
- Sends scanned, parsed, xml-serialized badge info to the Flash swf hosted inside the app
- Listens for & processes calls made by the Flash swf back to the WinForms shell to write data from swf to DB (after deserializing & parsing)
It’s Worked Great for Years, Why Change It?
Most of the backend was written in .NET 1.1 (still uses strongly-typed datasets), and I’d like to update it & get it out of WinForms.
For a long time, I envisioned it being rearchitected using either WPF or Silverlight so I could work with my objects without having to serialize, deserialize & parse xml to communicate with the UI (Flash swf).
As wonderful as that could be, our designers are on Macs so XAML adoption by our Flash team isn’t on the table.
The problem is, I don’t know how to approach this.
According to this article, every USB device has a unique device id. We have full control over the systems & own the scanners, so those could live in a static config file.
As of June 2011, there is now even a Scanner SDK for Windows.
In Conclusion, this is what I need to do with the Scanner:
1. Listen for a scan by the device
2. Parse the data (to verify the scan is what we were expecting for the app)
THAT’S REALLY IT. So how do I get that functionality out of my WinForms Controller? If you have any ideas, PLEASE feel free to comment (or find me if you’re at //BUILD/ – I’d love to discuss!)
The MiniMag swipe scanner can be ignored for now (I’ll cross that bridge if I figure out the one that DOES already have an SDK).