Home > OS >  Windows 10 detect keyboard layout change
Windows 10 detect keyboard layout change

Time:02-19

I'm trying to implement a service that would monitor language/layout changes. I switch between English and Russian languages. So far I've found this question and tried to implement and install both sinks suggested there. However, there are problems. ITfActiveLanguageProfileNotifySink::OnActivated is not triggered at all; ITfLanguageProfileNotifySink::OnLanguageChange is not triggered, too; ITfLanguageProfileNotifySink::OnLanguageChanged is triggered only when the main window of my program is in foreground, but it doesn't contain any information on the language. Is there any way to monitor input language change event globally?

CodePudding user response:

I found another way to detect such changes: to use SetWindowsHookEx with WH_SHELL. One of the available event is HSHELL_LANGUAGE which is exactly what I need and the test project seems to work just fine. There's an article by Alexander Shestakov that describes a program very similar to what I'm trying to achieve and it also has a link to github project that I use as an example.

  • Related