Can barcodes be scanned in the background while in progress?

I am making a web based sports management application that processes input. Members have a barcode on the tag that they scan when they arrive at the gym.

I've heard that most barcode scanners just act like a keyboard. This will require the scan page to be open and in the foreground when the barcode is scanned.

If it's just a keyboard, how can I send the input of the barcode scanner to one background process running on the computer and ignore it by all processes that might be in focus?

+3


source to share


2 answers


You are correct that most scanners can support HID in keyboard emulation, but this is just the beginning.

If you want a little control over the data, you can use scanners that support the OPOS driver model.
Take a look at the Zebra Windows SDK to see what you can do. This might be a better solution than trying to steal the barcode data coming into the OS in the form of keyboard input to the foreground application.



Disclaimer: I work for Zebra Technologies
Other manufacturers of barcode scanners support a similar driver model.

+1


source


I found an interesting post with a simple solution:

In the form constructor

InitializeComponent():
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Form1_KeyPress);

      

Handler and supporting elements:



DateTime _lastKeystroke = new DateTime(0);
List<char> _barcode = new List<char>(10);

private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
    // check timing (keystrokes within 100 ms)
    TimeSpan elapsed = (DateTime.Now - _lastKeystroke);
    if (elapsed.TotalMilliseconds > 100)
        _barcode.Clear();

    // record keystroke & timestamp
    _barcode.Add(e.KeyChar);
    _lastKeystroke = DateTime.Now;

    // process barcode
    if (e.KeyChar == 13 && _barcode.Count > 0) {
        string msg = new String(_barcode.ToArray());
        MessageBox.Show(msg);
        _barcode.Clear();
    }
}

      

Credits: @ltiong_sh

Original post: Here

0


source







All Articles