<tfoot id='MT5cV'></tfoot>

  • <small id='MT5cV'></small><noframes id='MT5cV'>

    • <bdo id='MT5cV'></bdo><ul id='MT5cV'></ul>
    <legend id='MT5cV'><style id='MT5cV'><dir id='MT5cV'><q id='MT5cV'></q></dir></style></legend>
      <i id='MT5cV'><tr id='MT5cV'><dt id='MT5cV'><q id='MT5cV'><span id='MT5cV'><b id='MT5cV'><form id='MT5cV'><ins id='MT5cV'></ins><ul id='MT5cV'></ul><sub id='MT5cV'></sub></form><legend id='MT5cV'></legend><bdo id='MT5cV'><pre id='MT5cV'><center id='MT5cV'></center></pre></bdo></b><th id='MT5cV'></th></span></q></dt></tr></i><div id='MT5cV'><tfoot id='MT5cV'></tfoot><dl id='MT5cV'><fieldset id='MT5cV'></fieldset></dl></div>

        如何判断键盘输入是否来自条形码扫描仪?

        时间:2023-07-26

            1. <tfoot id='jMG5H'></tfoot>

              <small id='jMG5H'></small><noframes id='jMG5H'>

              <i id='jMG5H'><tr id='jMG5H'><dt id='jMG5H'><q id='jMG5H'><span id='jMG5H'><b id='jMG5H'><form id='jMG5H'><ins id='jMG5H'></ins><ul id='jMG5H'></ul><sub id='jMG5H'></sub></form><legend id='jMG5H'></legend><bdo id='jMG5H'><pre id='jMG5H'><center id='jMG5H'></center></pre></bdo></b><th id='jMG5H'></th></span></q></dt></tr></i><div id='jMG5H'><tfoot id='jMG5H'></tfoot><dl id='jMG5H'><fieldset id='jMG5H'></fieldset></dl></div>

                • <bdo id='jMG5H'></bdo><ul id='jMG5H'></ul>
                • <legend id='jMG5H'><style id='jMG5H'><dir id='jMG5H'><q id='jMG5H'></q></dir></style></legend>
                    <tbody id='jMG5H'></tbody>

                  本文介绍了如何判断键盘输入是否来自条形码扫描仪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在一台计算机上,我有一个普通键盘和一个模拟键盘的条形码扫描仪.当我的应用获得键盘输入时,我如何确定该输入是来自条形码扫描仪还是真正的键盘?

                  On one computer I have both a regular keyboard and a barcode scanner which emulates a keyboard. When my app gets keyboard input, how can I determine whether that input is coming from the barcode scanner or the real keyboard?

                  推荐答案

                  你会得到双方的意见.当然,不是同时.它将全部放入队列中,但 Windows 将处理来自两个键盘的键事件.

                  You'll get input from both. Not simultaneously, of course. It will all be placed into a queue, but Windows will process key events from both keyboards.

                  不过,不要束手无策.正如 David Heffernan 所建议的那样,您可以通过将两个键盘都插入计算机,打开记事本并输入随机字符以查看哪个生成输入来轻松解决这个问题.

                  Don't be helpless, though. As David Heffernan suggests, you can easily figure this out yourself by plugging in both keyboards to your computer, opening up Notepad, and typing random characters to see which one generates input.

                  您回复说您想使用 C# 代码检查",但我不知道这意味着什么.如何创建一个从键盘读取输入并将其显示在屏幕上的控制台应用程序?

                  You reply that you want to "check that with C# code", but I have no idea what that means. How about creating a console app that reads input from the keyboard and displays it on the screen?

                  using System;
                  
                  class AdvancedKeyboardTester
                  {
                     static void Main(string[] args)
                     {
                        for (; ;)
                        {
                           Console.ReadKey();
                        }
                     }
                  }
                  

                  当您玩腻了想要退出程序时,请按 Ctrl+C.

                  Press Ctrl+C when you tire of the fun and want to quit the program.

                  听起来您正在寻找 RegisterRawInputDevices 函数,它允许您为所有键盘启用原始输入,然后枚举结果以确定哪个设备发送了消息.

                  It sounds like you're looking for the RegisterRawInputDevices function, which allows you to enable raw input for all of your keyboards, and then enumerate through the results to determine which device sent the message.

                  幸运的是,看起来有人已经为此编写了一个 C# 包装库,可在 Code Project 上下载:使用 C# 的原始输入来处理多个键盘

                  Fortunately, it looks like someone has already written a C# wrapper library for this, available for download on Code Project: Using Raw Input from C# to handle multiple keyboards

                  编辑 2:(似乎信息只是不断从评论中欺骗)

                  Edit 2: (it seems the information just keeps tricking in from the comments)

                  如果您使用的是条形码扫描仪,这会容易得多.因为它们是专门为此目的而设计的,所以它们几乎都是可编程的.这意味着您可以告诉他们为他们的输入添加前缀(和/或后缀)一些标记字符,这些字符表明输入来自条形码扫描仪,而不是标准键盘.(查看条形码扫描仪的用户手册以获取更多信息.)然后,您所要做的就是根据这些标记字符的存在与否过滤掉键盘输入.您还可以检查输入前缀和后缀之间的字符的速度.

                  If you're using a barcode scanner, this gets a lot easier. Because they're explicitly designed for this purpose, they're almost all programmable. Meaning that you can tell them to prefix (and/or suffix) their input with some sentinel characters that indicate the input is coming from the barcode scanner, rather than a standard keyboard. (Check your barcode scanner's user manual for more information.) Then, all you have to do is filter out the keyboard input based on the presence or absence of those sentinel characters. You can also check for how quickly the characters between the prefix and suffix were entered.

                  这篇关于如何判断键盘输入是否来自条形码扫描仪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 SendKeys 发送特殊字符 下一篇:如何使用 C# 按下一个键并释放它?

                  相关文章

                    <bdo id='v6lK5'></bdo><ul id='v6lK5'></ul>

                  <small id='v6lK5'></small><noframes id='v6lK5'>

                • <tfoot id='v6lK5'></tfoot>
                    <legend id='v6lK5'><style id='v6lK5'><dir id='v6lK5'><q id='v6lK5'></q></dir></style></legend>

                      <i id='v6lK5'><tr id='v6lK5'><dt id='v6lK5'><q id='v6lK5'><span id='v6lK5'><b id='v6lK5'><form id='v6lK5'><ins id='v6lK5'></ins><ul id='v6lK5'></ul><sub id='v6lK5'></sub></form><legend id='v6lK5'></legend><bdo id='v6lK5'><pre id='v6lK5'><center id='v6lK5'></center></pre></bdo></b><th id='v6lK5'></th></span></q></dt></tr></i><div id='v6lK5'><tfoot id='v6lK5'></tfoot><dl id='v6lK5'><fieldset id='v6lK5'></fieldset></dl></div>