Jquery Barcode Scanner Integration

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 17:50:23

问题


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>

回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/10665392/jquery-barcode-scanner-integration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!