windows 以编程方式为条码扫描仪设置前缀/后缀

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2412026/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 14:06:05  来源:igfitidea点击:

Set prefix/suffix to a Barcode Scanner programmatically

windowsbarcode-scanner

提问by kampi

I want to create an application, where I can set, what prefix or suffix i want to send to the Barcode reader. The barcode reader may connect to the PC with USB or RS-232 ports. I mean if I have a barcode like "4567", and I set in my application that it should send a prefix like "123"to the barcode scanner, than if I read my barcode ("4567") into a text editor, it should display "1234567".

我想创建一个应用程序,我可以在其中设置要发送到条形码阅读器的前缀或后缀。条码阅读器可以通过 USB 或 RS-232 端口连接到 PC。我的意思是,如果我有一个像 的条形码"4567",并且我在我的应用程序中设置它应该向"123"条形码扫描仪发送一个前缀,而不是如果我将我的条形码 ( "4567")读入文本编辑器,它应该显示"1234567".

How can I do this?

我怎样才能做到这一点?



Update:

更新:

I need to use Symbol LS2208 Barcode Reader. Using the programming guide I was able, to put one character before the barcode, but I need 4 (at least). Other possibility is to put 3 charachters before the barcode, but I can't bring this method to work, and if I were able, then I should put the 4th digit there somehow.

我需要使用 Symbol LS2208 条码阅读器。使用编程指南,我可以在条形码前放置一个字符,但我需要 4 个(至少)。另一种可能性是在条码前放 3 个字符,但我无法使用这种方法,如果可以的话,我应该以某种方式将第 4 位数字放在那里。

Correct me if I'm wrong, but shouldn't be there a possibility to do programmatically what I want? I think it should work like this: connect to the USB/serial port. Capture if the user did read something with the barcode reader. After capturing modifying it, and then put it there where it has been read.

如果我错了,请纠正我,但不应该有可能以编程方式执行我想要的操作吗?我认为它应该像这样工作:连接到 USB/串行端口。捕获用户是否使用条码阅读器读取了某些内容。捕获后修改它,然后把它放在已经读过的地方。

回答by Harvey

According to the Symbol LS2208 Product Reference Guide, it says you can set up to four digits for prefix and suffix. It looks like the USB interface just acts like a keyboard input or like a serial input (configurable).

根据Symbol LS2208 产品参考指南,它说您最多可以设置四位前缀和后缀。看起来 USB 接口就像键盘输入或串行输入(可配置)。

Update: the four digits are a special character code. I.e. you only get one character for the four digits.

更新:四位数字是特殊字符代码。即你只能得到四位数字的一个字符。

回答by Romain Hippeau

This may not answer your question, but here goes anyways.

这可能无法回答您的问题,但无论如何都在这里。

We use Symbol barcode readers (Used to be Serial, Now USB to Serial Port converters) reading from the serial port. Our code is written in Java and use the Java Communications API (Reads/Writes Serial/Parallel ports). We then take the input from the Serial Port and send it to the window that has the focus in a Swing Application. Since the application has access to the inbound stream we can modify the stream however we want.

我们使用 Symbol 条形码阅读器(以前是串行,现在是 USB 到串行端口转换器)从串行端口读取。我们的代码是用 Java 编写的,并使用 Java Communications API(读/写串行/并行端口)。然后我们从串行端口获取输入并将其发送到具有 Swing 应用程序焦点的窗口。由于应用程序可以访问入站流,我们可以根据需要修改流。