简体   繁体   中英

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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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