简体   繁体   English

Windows输入语言已更改C#

[英]windows inputlanguage changed c#

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). 我正在Visual Studio(Windows应用程序)中的一个简单程序上工作,我需要知道用户何时更改键盘语言(我不在乎是什么语言还是现在是什么)。

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. 示例:我将打开Goog​​le chrome并更改语言,将不会调用此函数。

I need to get the specific windows keyboard changed. 我需要更改特定的Windows键盘。 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. ty们。

As far s I know, in Windows, input language is specific for process. 据我所知,在Windows中,输入语言特定于过程。 So you get the InputLanguageChanged event for your application. 因此,您将为应用程序获取InputLanguageChanged事件。 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. 例如,定期检查活动窗口并使用GetKeyboardLayout API函数获取键盘布局。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM