如何通过c#代码更改键盘布局 [英] How to change keyboard layouts through c# code

查看:102
本文介绍了如何通过c#代码更改键盘布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一种多语言应用程序,允许用户更改语言和键盘布局(通过组合框)。我能够成功地改变应用程序的文化,但我无法更改单个键盘布局,例如对于英语(美国),我无法将布局从QWERTY(默认)改为Dvorak - 左手等.Plz帮我解决了这个问题。非常感谢这里的代码(例如英语),已经添加了导入等。

i am developing a multi-lingual application allowing users to change language as well as keyboard layouts (through combobox). I am able to change the culture of application successfully but i'm unable to change the individual keyboard layouts e.g. for English (United States), im unable to change layouts from QWERTY (default) to Dvorak - Left hand etc.. Plz help me in this matter. Thanks alot Here's the code (e.g. for English language), the imports etc are added already..

CultureInfo TypeOfLanguage = CultureInfo.CreateSpecificCulture("en-US");
System.Threading.Thread.CurrentThread.CurrentCulture = TypeOfLanguage;
InputLanguage l = InputLanguage.FromCulture(TypeOfLanguage);
InputLanguage.CurrentInputLanguage = l;

推荐答案

MSDN示例 - 用C#更改键盘布局 [ ^ ]



我知道它与你发布的相似,但我有一种感觉你的问题是获得正确的输入语言。请参阅链接示例了解有效的内容,并查看代码中的差异。
MSDN Sample - Change Keyboard Layout in C#[^]

I know its similar to what you posted, but I have a feeling that your issue is in obtaining the correct input language. See the linked example for something that works and see where the difference is in your code.


这篇关于如何通过c#代码更改键盘布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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