简体   繁体   中英

Jquery Barcode Scanner Integration

How can I emulate keyboard press once I scanned a barcode using a usb barcode scanner? I don't have any idea about this and I just want to get some suggestions/instructions on how can I do it. If I have this form, how will the barcode number be inputted in that textbox? thanks!

<form method="post" action="">
    <input type="text" id="barcode-input" name="barcode-input" value=""/>
</form>

The barcode scanners that I have seen (not that many I have to admit) act like a keyboard. Old ones even have a PS/2 port. But even the USB ones like to just identify themselves as a keyboard. When you scan a code, the scanner behaves as if you would have actually pressed number keys on your keyboard, probably ending with a return key.

So what you do is put a focus in your textbox, and scan your code and be done.

If your scanner doesn't work like a keyboard, and you have to get the code programmatically, you'll have to use an automation tool.

Depending on what language you're working with, and what OS you're working in, there may be several automation options for sending keys, but most of them won't be able to find and select your text field. You'd have to position the cursor yourself, and then use an automation tool to just push the keys for you.

If you're on Windows, PyWinAuto is the favorite choice of several of my co-workers. It has a simple but reliable API for doing these kinds of basic automated tasks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM