获取条形码阅读器提交的代码 [英] get the code submitted by barcode reader

查看:95
本文介绍了获取条形码阅读器提交的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在开发使用条形码阅读器的wpf应用程序,我想在扫描条形码后获取代码,我创建了一个按键按下事件并尝试获取输入的密钥,但是只有我才能获取第一个密钥我得到了所有代码(所有按下的键)

hi guys ,
i am developing a wpf application that use bar code reader , i want to get the code when the bar code has been scanned the code i create an key down event and try to get the keys that entered but only i get the first key how can i get all the code (all the pressed keys)

private void Grd_Main_KeyDown(object sender, KeyEventArgs e)
        {
            MessageBox.Show(e.Key.ToString());

        }



有人可以帮我吗?
感谢高级...



can any one help me in doing that ?
thanks an advanced ...

推荐答案

通常会有一个结尾字符,可以在阅读器上进行配置.可以是特殊的,也可以是Tab键,然后按Enter.但是,如果您使用的是通用条形码读取器,您将永远不会知道用户是否按下了按键,或者它是否来自读取器.
但是由于阅读器只是另一台HID设备,因此您应该能够将其作为单独的键盘进行处理.在此处检查如何:使用来自C#的原始输入来处理多个键盘 [ ^ ].这样,您将能够以不同方式处理来自实际键盘和读取器的按键.
Typically there is an ending character, that can be configured on the reader. Can be a special one or Tab, Enter. But if you are using a general barcode reader, you will never know if a user pressed a key, or it came from the reader.
But as the reader is just an other HID device, you should be able to handle it as a separate keyboard. Check here how: Using Raw Input from C# to handle multiple keyboards[^]. This way, you will be able to handle differently the keys coming from the actual keyboard, and the reader.


您需要使用类似.NET v1.12的Microsoft服务点(.NET的POS) [ UnifiedPOS页面 [此处 [
You need to use something like Microsoft Point of Service for .NET v1.12 (POS for .NET)[^]

Microsoft Point of Service for .NET v1.12 (POS for .NET) is a class library that enables POS developers to apply Microsoft .NET technologies in their products. It provides a simple and consistent interface for .NET Framework applications to interact with POS devices, in compliance with the UnifiedPOS standard (aka UPOS). In addition, it provides windows plug and play (PnP) support. There are thirty-six classes of POS peripherals supported including cash drawer, receipt printer, barcode scanner, magnetic strip reader (MSR), line display, RFID, Biometric, Belt, Check Scanner, Fiscal Printer, Electronic Journal, Image Scanner, Item Dispenser, Magnetic Ink Character Recognition Reader (MICR), PIN Pad, signature capture device, etc. In addition, POS for .NET supports many legacy devices where OPOS service objects are available.

This is considered the preferred way to interact with POS devices from .Net.

You can also have a look at the UnifiedPOS page[^]

In case you are using a Symbol scanner you can download the opos driver from
here[^]

Update

Microsoft Point of Service for .NET v1.12 is a set of .Net assemblies, all you need to do is to add a reference to the assembly.

OPOS is COM based, so you need to import the type library for the dll into .Net, which you can do in nearly the same manner you import .Net assemblies.

So both technologies are easily accessible from C# and .Net.

Best regards
Espen Harlinn


首先,正如肯尼思已经指出的那样,收集所有角色.

例如,如果代码的长度为12个字符,则在窗口级别上创建一个字符串变量,并将各个字符累积到其中.当字符串的长度为12时,您就有了代码.

第二件事,如果您想获取代码而无论焦点在哪里,请利用冒泡路由.我的意思是,例如,您可以仅在窗口上定义KeyDown,因此无论当前在窗口上的焦点如何,事件都将在一个地方处理.根据用户界面和要求以及您识别条形码的方式,这可能是可行的策略,也可能不是可行的策略.
First of all as Kenneth already pointed out, gather all the characters.

For example if the length of the code is 12 characters, create a string variable on window level and accumulate the individual characters into it. When the length of the string is 12, you have your code.

Second thing, if you want to get the code regardless where the focus is, take advantage of bubbling routing. What I mean is that you can for example define the KeyDown on the Window solely so regardless of the current focus on the window, the event would be handled in a single place. This may or may not be a feasible strategy depending on the UI and the requirements and how you recognize the barcode.


这篇关于获取条形码阅读器提交的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆