简体   繁体   English

带有 C++ 控制台程序的 USB 条码扫描仪

[英]USB Barcode Scanner with C++ Console Program

I know this isn't exactly a programming question, but it is related:我知道这不完全是一个编程问题,但它是相关的:

I'd like to know if USB barcode scanners can scan a barcode and type the results as if it was a keyboard.我想知道 USB 条码扫描器是否可以扫描条码并像键盘一样输入结果。 The reason for this is that I would like to make a C++ console application that will take the input of the scanner using cin or getline , but that would only work if the barcode scanner types the results into my program like a keyboard, and I would like the scanner to press enter for me so I can just scan and scan without pressing it myself in between.这样做的原因是我想制作一个 C++ 控制台应用程序,它将使用cingetline接受扫描仪的输入,但只有当条形码扫描仪像键盘一样将结果输入到我的程序中时,这才有效,我会像扫描仪一样为我按下 Enter 键,这样我就可以扫描和扫描,而无需自己在两者之间按下它。

If it doesn't work like that, then how can I get the barcode scanner to give the variable with the results to my program?如果它不能那样工作,那么我怎样才能让条形码扫描仪将带有结果的变量提供给我的程序? Is there a special cheap barcode scanner with a C++ api?是否有带有 C++ api 的特殊廉价条码扫描仪?

I would test this myself, but I am a teen with no money and I don't want to bother my parents for a scanner just to waste their money if it doesn't work.我会自己测试这个,但我是一个没有钱的青少年,我不想为了扫描仪而打扰我的父母,如果它不起作用就浪费他们的钱。

EDIT: If there is some 3rd party api thing, I don't want to have to type so much confusing code, I would just like to type something like: barcodeResults = scanBarcodeAPI();编辑:如果有一些 3rd 方 api 的东西,我不想输入这么多令人困惑的代码,我只想输入类似的东西: barcodeResults = scanBarcodeAPI();

All the barcode scanners I've dealt with have emulated a keyboard.我接触过的所有条码扫描器都模拟了键盘。 (In fact, a more common question seems to be how to distinguish scanner input from keyboard input. For example, see How do I tell if keyboard input is coming from a barcode scanner? ) (实际上,一个更常见的问题似乎是如何区分扫描仪输入和键盘输入。例如,请参阅如何判断键盘输入是否来自条码扫描仪?

Having the scanner add <ENTER> to the end of the barcode is a common configuration (of the scanner).让扫描仪在条形码末尾添加<ENTER>是(扫描仪的)常见配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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