键盘类型(QWERTY键盘或德沃夏克)检测 [英] Keyboard Type (Qwerty or Dvorak) detection

查看:157
本文介绍了键盘类型(QWERTY键盘或德沃夏克)检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被一个朋友问到这个问题,它激起了我的好奇心,我一直无法找到解决它,所以我希望有人会知道。

I was asked this question by a friend, and it piqued my curiosity, and I've been unable to find a solution to it yet, so I'm hoping someone will know.

有什么方法以编程方式检测用户在使用什么类型的键盘?我的键盘的理解是,发送到计算机A一个DVORAK键盘上的信号是相同的发送到计算机用于在QUERTY键盘的A的信号。但是,我读过有关如何从德沃夏克 开关/,这彰显注册表调整,但我希望有一台机器的设置,或者我可以查询一些其他的事情。

Is there any way to programatically detect what type of keyboard a user is using? My understanding of the keyboard is that the signal sent to the computer for 'A' on a DVORAK keyboard is the same as the signal sent to the computer for an 'A' in a QUERTY keyboard. However, I've read about ways to switch to/from dvorak, that highlight registry tweaking, but I'm hoping there is a machine setting or some other thing that I can query.

任何想法?

推荐答案

您可以通过调用GetKeyboardLayoutName()Win32 API的方式做到这一点。
德沃夏克键盘有特定的名称。例如,美国Dvorak布局具有00010409的名称

You can do this by calling the GetKeyboardLayoutName() Win32 API method. Dvorak keyboards have specific names. For example, the U.S. Dvorak layout has a name of 00010409.

code片断:

  public class Program
  {
    const int KL_NAMELENGTH = 9;

    [DllImport("user32.dll")]
    private static extern long GetKeyboardLayoutName(
          System.Text.StringBuilder pwszKLID); 

    static void Main(string[] args)
    {
      StringBuilder name = new StringBuilder(KL_NAMELENGTH);

      GetKeyboardLayoutName(name);

      Console.WriteLine(name);

    }
  }

这篇关于键盘类型(QWERTY键盘或德沃夏克)检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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