如何在.net中全局更改系统输入语言

发布于 2024-12-02 15:53:48 字数 752 浏览 1 评论 0原文

我经常在 qwerty 和 dvorak 之间切换,Windows 中最大的不便之一是,虽然有一个热键可以在输入语言之间切换,但它只能更改具有焦点的窗口的输入语言。

我想创建一个脚本来更改我的输入语言,并在按下热键时运行该脚本。我一直在尝试不同的方法来做到这一点。我需要这个的原因是因为我更喜欢在工作时一直输入 dvorak,但无法将系统默认设置为 dvorak,以防其他人需要使用我的系统。脚本完成后,我可以将其上传以供所有人下载和使用。

我在网上找到的一种解决方案是使用 SystemParametersInfo 函数。但是,我无法从 MSDN 库中找到足够的文档来实现此功能。在阅读了其他人无法使此功能正常工作的几篇文章后,我停止了搜索,其中一些人指出它需要重新启动系统。

编辑 - 后续尝试失败,因为似乎此方法仅适用于当前窗口(虽然我能够更改输入语言,但它似乎没有任何效果)。

另一个(稍微多一点)有希望)我发现的解决方案是设置InputLanguage.CurrentInputLanguage。然而,关于它用于设置的用法的文档很少(更多用于获取)。我为此找到的在线指南讨论了使用 InputLanguage.FromCulture() 设置语言。即 InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(new System.Globalization.CultureInfo("ZH-CN")); 但是 US-Dvorak 似乎不在受支持的文化列表中。

有人有什么想法吗?谢谢!

I commonly switch between typing in qwerty and dvorak, and one of the biggest inconveniences in Windows is that although there is a hot key to switch between input languages, it only changes the input language for the window that has focus.

I would like to create a script to change the input language for me and have the script run when I press a hot key. I have been experimenting with different ways to do this. The reason I need this is because I prefer to type in dvorak all the time at work, but cannot set the system default to dvorak in case someone else needs to use my system. Once the script is done I can upload it for all to download and use.

One solution I found online was using the SystemParametersInfo function. However I could not find adequate documentation to get this working from the MSDN library. I stopped searching after reading several posts by others who were unable to get this function working, some stating that it requires a system reboot.

Edit - the proceeding attempt failed because it seems this method only works for the current window (and although I was able to change the input language, it did not appear to have any effect).

Another (slightly more promising) solution I found was setting InputLanguage.CurrentInputLanguage. However again there is very little documentation on it's usage for setting (more for just getting). The online guides I found for this discussed using InputLanguage.FromCulture() to set the language. ie InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(new System.Globalization.CultureInfo("ZH-CN")); however US-Dvorak does not appear to be in the list of supported cultures.

Does anyone have any ideas? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北风几吹夏 2024-12-09 15:53:49

我发现这个程序:效果很好,并且提供了源代码。当我尝试开发其他程序来“修复”Windows 糟糕的功能时,我可能会使用它作为资源。

下载:http://www.tomseddon.plus.com/kbswitch/

如果您是使用Windows 7,您可以将其拖出屏幕右下角的“弹出框”,以便该图标位于任务栏中,靠近系统时间。我没有尝试过重新启动,我想将程序放在启动文件夹中,所以它应该可以工作。

I found this program: Works great, and the source code is provided. I might use it as a resource when trying to develop other programs to "fix" Windows' awful functionality.

Download: http://www.tomseddon.plus.com/kbswitch/

If you're using Windows 7 you can drag it out of the "Pop-Up Box" in the bottom right corner of the screen, so that the icon sits in the taskbar, near the system time. I haven't tried rebooting, I put the program in the start-up folder thought, so it should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文