简体   繁体   中英

Windows 10 detect keyboard layout change

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?

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.

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