使用VB.NET代码选择键盘布局 [英] Chosing keyboard layout using VB.NET code

查看:216
本文介绍了使用VB.NET代码选择键盘布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经安装了适用于乌尔都语的语音键盘,可以从控制面板">中选择语言>键盘
我可以使用VB.NET代码添加语言并选择键盘吗?

谢谢

Hi,

I have installed Phonetic Key board for Urdu language, that I can select from Control Panel > Languages > Keyboard
Can I add languages and select keyboard using my VB.NET code?

Thanks

推荐答案

我不认为您可以轻松添加新的键盘布局,但可以在应用程序中进行切换.这取决于您使用的应用程序类型或UI.您应该在问题中标记它.

我强烈建议您不要在操作系统级别上这样做.您的用户更清楚每时每刻使用哪种语言.而且,没有人应该配置系统选项,例如一组输入语言和用于切换它们的键盘快捷键.它不必是Alt + Shift.仅应允许用户或受用户信任的系统管理员来执行此操作.简单的安全性问题和简单的常识决定了它.

但是,如果您如此固执地忽略了此建议,则可以尝试使用P/Invoked Windows API SendInput,请参阅 ^ ].您也可以通过WMI进行操作. 不要这样做!

相反,您可以只为应用程序选择输入语言.这样好多了.但是我会说最好将它留给用户.


使用表单,您可以切换输入语言,但只能针对您的应用程序,这可能对您更好:
I don''t think you can easily add a new keyboard layout, but you can certainly switch them in your application. It depends on application type or UI you are using. You should have tagged it in your question.

I would strongly recommend you refrain from doing it at the level of OS. Your user knows better what language to use at every moment. Moreover, nobody should configure system options like a set of input languages and keyboard shortcut for switching them. It does not have to be Alt+Shift. Only the user or a system administrator trusted by a user should be allowed to do it. Simple security issues and simple common sense dictate it.

However, if you are so stubborn to ignore this advice, you can try P/Invoked Windows API SendInput, see http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310%28v=vs.85%29.aspx[^]. You can do it via WMI as well. Don''t do it!

Instead, you can select the input language just for your application; this is much better. But I would say leaving this to a user is preferable.


With Forms, you can switch input language, but only for your application, which might be much better for you:
Windows.Forms.InputLanguage.CurrentInputLanguage = someLanguage;


请参阅 http://msdn.microsoft.com/en-us/library/system .windows.forms.inputlanguage.aspx [ ^ ].

使用WPF,可以将类System.Windows.Input.InputLanguageManager用于相同的目的.请参阅 http://msdn.microsoft.com/en-us/library/system .windows.input.inputlanguagemanager.aspx [ ^ ].

—SA


See http://msdn.microsoft.com/en-us/library/system.windows.forms.inputlanguage.aspx[^].

With WPF, you can use the class System.Windows.Input.InputLanguageManager for the same purpose. See http://msdn.microsoft.com/en-us/library/system.windows.input.inputlanguagemanager.aspx[^].

—SA


使用此API

1-创建此功能
公共声明函数LoadKeyboardLayout Lib"user32"别名"LoadKeyboardLayoutA"(ByVal pwszKLID为字符串,ByVal标志为长)

2-在表单中称为

LoadKeyboardLayout("00000429",1)"设置波斯语键盘的布局

您可以在控制面板>中找到布局代码("00000429").区域和语言
use this API

1 - Create this function
Public Declare Function LoadKeyboardLayout Lib "user32" Alias "LoadKeyboardLayoutA" (ByVal pwszKLID As String, ByVal Flags As Long) As Long

2 - and in forms call this

LoadKeyboardLayout("00000429", 1) ''to set persian keyboard layout

u can find the layout code("00000429") in control panel > regional and Language


这篇关于使用VB.NET代码选择键盘布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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