窗口输入语言改变了c#语言[英] windows inputlanguage changed c#

本文是小编为大家收集整理的关于窗口输入语言改变了c#语言的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

本文来自:IT宝库(https://www.itbaoku.cn)

我正在研究Visual Studio(Windows应用程序)中的简单程序,我需要知道用户何时更改键盘语言(我不在乎语言是什么或现在是什么).

我尝试了此代码:

 private void MainForm_InputLanguageChanged(object sender, InputLanguageChangedEventArgs e)
    {

    }

但是,当表单活跃并专注时,它只会在形式中以语言变化!示例:我将打开Goog​​le Chrome并更改语言,此功能不会被调用.

我需要更改特定的Windows键盘.不是更改形式的输入语言.

对我来说非常重要的

ty Guys.

推荐答案

我知道,在Windows中,输入语言是特定于过程的.因此,您可以为您的应用程序获得InputLanguageChanged事件.如果您想在全球范围内通知语言变化,则应该自己做.例如,定期检查活动窗口并使用getKeyboardlayout API函数获取键盘布局.

本文地址:https://www.itbaoku.cn/post/2352722.html

问题描述

I am working on a simple program in Visual studio(windows application) and I need to know when the user is changing the keyboard language(I don't care what was the language or what it is now).

I have tried this code:

 private void MainForm_InputLanguageChanged(object sender, InputLanguageChangedEventArgs e)
    {

    }

But it will only get the language change in the form when the form is active and focused! Example: I'll open Google chrome and change the language, this function will not be called.

I need to get the specific windows keyboard changed. Not the form inputlanguage changed..

it's very important for me I am breaking my head about a week for this so please help.

ty guys.

推荐答案

As far s I know, in Windows, input language is specific for process. So you get the InputLanguageChanged event for your application. If you want to be notified of language change globally, you should do it on your own. For example periodically check the active window and get keyboard layout using GetKeyboardLayout API function.