How to figure out what is stealing focus in Windows
I had an issue a week ago. Something was stealing focus in Windows 11 and it was super annoying. Every 20 seconds something was stealing the focus away from the window I was trying to do work on. Playing games, watching a full screen video, coding, or typing, something was messing up my work and personal productivity. I had to fix it! After much research, many people gave the, quite frankly stupid, advice of restarting your computer, reinstalling windows, running a virus scan, etc. I don’t install random torrent programs or other things like that so it’s not a virus. Also reinstalling windows was not an option.
I found this program called focus https://www.happydroid.com/focus. I found the program from this thread https://superuser.com/questions/301183/how-to-detect-a-background-program-in-windows-7-which-steals-active-focus-auto. I tried a couple of other programs, none of them worked, but this one did. It’s quite simple, run it and every time a new window gets focus, it logs it in the terminal….
Ok, so I figured out what was stealing focus. Turns out a program called mstsc.exe was the perpetrator. I finally found this thread about it https://answers.microsoft.com/en-us/windows/forum/all/mstscexe-stealing-focus/f9acb6fd-3c95-4e22-8f40-dc41dffbb178. At the bottom of the thread I followed the link to this article https://x410.dev/cookbook/wsl/disabling-wslg-or-using-it-together-with-x410/ (Web Archive link). I ended up following the steps and it worked out! It no longer steals focus every 20 seconds!
Hopefully that helps you solve your focus stealing issue. I have included a backup of the focus program HERE in case it ever is no longer offered by happydroid. I found so many programs that were no longer available in the process of trying to solve this.