在vb.net应用程序上使用条形码阅读器 [英] Using a barcode reader on a vb.net application

查看:68
本文介绍了在vb.net应用程序上使用条形码阅读器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!


我正在编写一个应该使用USB条形码阅读器的应用程序。该应用程序应该是通用的,可以与任何USB条形码阅读器一起使用(这些条形码阅读器主要用作简单的键盘)


但我有一些问题需要解决:


1。当文本框聚焦时,我想区分 如果用户从键盘输入了字符,或者从条形码阅读器中读取了字符。


2。当文本框被聚焦并且用户从条形码阅读器读取时,我想要一种允许或拒绝条形码显示在该文本框上的方法。


3。当没有文本框被聚焦时,我希望能够在后台阅读条形码,我的意思是,如果用户在阅读条形码时,表格打开并且另一个控件聚焦(不是文本框),我怎么能够将条形码保存在变量
并且不在任何地方显示?



谢谢!

解决方案


1。当文本框聚焦时,我想区分 如果用户从键盘输入了字符,或者从条形码阅读器中读取了字符。


2。当文本框被聚焦并且用户从条形码阅读器读取时,我想要一种允许或拒绝条形码显示在该文本框上的方法。


3。当没有文本框被聚焦时,我希望能够在后台阅读条形码,我的意思是,如果用户在阅读条形码时,表格打开并且另一个控件聚焦(不是文本框),我怎么能够将条形码保存在变量
并且不在任何地方显示?


您将只能创建一个适用于任何 的应用程序;条形码阅读器,确保它被配置为充当键盘的精确替代品。 这通常意味着您的代码无法区分键盘和阅读器
,因为阅读器驱动程序非常努力使设备看起来与键盘完全相同,以使其尽可能兼容。  所以这两个目标是冲突的。


解决前两个问题的方法之一是配置读者在数据的开头或结尾插入一个魔术字符 并非所有读者都可以这样做,但如果可以这样做,那么你的代码可以查找神奇的字符
来决定它是键盘输入还是读者输入,然后如果找到它就扔掉它。 知道这个技巧的人(他们可以通过查看阅读器配置找到)可能会欺骗应用程序接受键盘输入
作为阅读器条目,因此系统不是特别安全。


如果将阅读器配置为键盘,则在不重定向键盘的情况下无法在"背景"中阅读。因此,您需要知道何时期望读者输入以及何时期望操作员输入。  这个过程几乎肯定会干扰
与操作员当时正在做的其他事情。 


如果您为特定读者编写应用程序,那么您可以管理来自该读者的输入,可能根据读者的需要做你想做的事。 有些仅在键盘模式下工作,有些在键盘和设备模式下工作。 
在这种情况下,您需要指定要使用的读卡器的品牌和型号,以确定它是否能够达到您想要的效果。




Hello !

I'm writing an application that should use a USB barcode reader. The application should be general and works with any USB barcode reader ( these barcode readers mostly acts as a simple keyboards )

But I have some problems that I want to resolve :

1. When a textbox is focused , I want to distinguish  if user has typed chars from keyboard or a read from barcode reader was made.

2. When a textbox is focused and user made a read from barcode reader , I want a way to allow or deny that the barcode be displayed on that textbox.

3. When no textbox is focused , I want to be able to read the barcode in background , I mean if in a moment a form is open and another control is focused ( not a textbox ) when the user read a barcode , how can I be able to keep the barcode on a variable and to not display it anywhere ?

Thank you !

解决方案

1. When a textbox is focused , I want to distinguish  if user has typed chars from keyboard or a read from barcode reader was made.

2. When a textbox is focused and user made a read from barcode reader , I want a way to allow or deny that the barcode be displayed on that textbox.

3. When no textbox is focused , I want to be able to read the barcode in background , I mean if in a moment a form is open and another control is focused ( not a textbox ) when the user read a barcode , how can I be able to keep the barcode on a variable and to not display it anywhere ?

You will only be able to create an application that works with any barcode reader by ensuring that it is configured to act as an exact substitute for a keyboard.  That usually means that your code cannot distinguish between keyboard and reader because the reader driver tries very hard to make the device look exactly like a keyboard, to make it as compatible as possible.  So those two objectives are in conflict.

One way around this that would address your first two issues is to configure the reader to insert a magic character at the start or end of the data.  Not all readers can do this, but if it can be done then your code can look for the magic character to decide whether it is keyboard or reader input, then throw it away if it is found.  Someone who knows the trick (and they could find out by looking at the reader configuration) might be able to fool the application into accepting keyboard entry as reader entry, so the system is not particularly secure.

If the reader is configured as a keyboard it cannot be read in the 'background' without redirecting the keyboard. So you would need to know when to expect reader input and when to expect operator input.   The process would almost certainly interfere with that other thing that the operator is doing at the time. 

If you write your application for a particular reader then you can manage the input from that reader, and probably do what you want, depending on what the reader is.  Some only work in keyboard mode, some work in both keyboard and device mode.  In that case you would need to specify the make and model of the reader you want to use in order to determine whether or not it can do what you want.



这篇关于在vb.net应用程序上使用条形码阅读器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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