I have a C# class that's responsible for monitoring focus changes globally.
It works via SetWinEventHook
with EVENT_SYSTEM_FOREGROUND
. See this question for details.
Everything works really well, but there's a weird problem...
When you're changing language on Windows 10 via Alt+Shift
a little menu pops up with the languages enabled on your system that you can select from.
Well, guess what, that thing sends a focus change event too...
The weird part is - the process that had the focus before the language change kinda... doesn't lose it? Because after that pop up menu disappears you don't get the focus change event for the window that was focused.
For example, I'm typing text in Notepad++ (notepad++
process name) and my program registered that, when I go and change language via Alt+Shift
that little pop up menu sends the focus event (explorer
process name) and upon disappearing Notepad++ doesn't send the focus event!
And even if I do something in Notepad++ afterwards, I will not get the focus event for it...
Only focusing on some other window (not Notepad++) will send the focus change event.
How do I overcome this issue?
Keep in mind, that I'm still interested in explorer
process, because File Explorer has that name. So, I can't just ignore all processes that are explorer
P.S. I also used this way of global focus monitoring, but it does the same thing.