区分扫描仪和键盘
嘿大家。 我有一台条形码扫描仪连接到一台使用 ac# 程序的 PC。现在我想区分扫描仪和键盘,哪一个正在向我的程序发送数据。 每个人都可以帮助我编写 c# 代码或提供建议吗?
有人在另一个主题中对我说了这句话(但我还不能这样做): 基本上,您可以配置扫描仪发送一些字符,这些字符基本上告诉计算机“嗨,是我”。当您在输入流中看到这些字符时,您就知道该信息来自条形码扫描仪,而不是用户在键盘上键入的内容。您检查过条码扫描仪随附的手册吗?它应该有更多关于这方面的信息。
hey all.
I have a barcode scanner connected to a PC that working with a c# program.now i want to distinguish between the scanner and the keyboard which one is sending data to my program.
can everyone help me with a code or advise in c#?
somebody said this to me in another topic(but i can't do this yet):
basically you can configure the scanner to send some characters that basically tell the computer "hi, it's me". When you see those characters in your input stream, you know the information is coming from the barcode scanner, not from something the user typed on the keyboard. Did you check the manual that came with your barcode scanner? It should have more information about this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看截至 2019 年 3 月的更新:
https://stackoverflow.com/a/55411255/495455
如果您的应用程序适用于特定条形码(例如所有相同的字符长度或者可以与正则表达式匹配的),那么您可以通过编写机器人打字测试来解决它。例如:
VB.Net:
C#:
See update, as at March 2019:
https://stackoverflow.com/a/55411255/495455
If your application works with particular barcodes (eg all same char length or ones that can be matched with a RegEx) then you could possibly work it out by coding up a Robot Typing test. eg:
VB.Net:
C#:
扫描数据通常以回车或换行字符结束,称为后缀。您也可以将扫描仪配置为包含前缀。这就是你的朋友想告诉你的。
The scan data will typically end with a carriage return or line feed character, called the suffix. You may be able to configure the scanner to include a prefix as well. That is what your friend was trying to tell you.