I just had a problem where something continuously kept stealing focus, preventing me from typing in VS Code. This is on Windows 11 22H2; I recognise that this is a very old question, but I think that further answers might still be helpful.
When I pressed Alt + Space to open the window handle menu, I got a menu that appeared to be attached to no window at all. I chose Move
and got a ‘window’ that was totally transparent, without any content, title text or decorations whatsoever; I just got a mouse cursor that indicated that I'm indeed moving a window. An attempt to close it from the handle menu wasn't successful; the ghost window stayed active and kept stealing focus.
I finally started to close all other applications one by one and tried to keep typing in VS Code. Finally, when I had closed a WSL (Debian) prompt in Windows Terminal the problem got solved.
Why the WSL prompt kept stealing the focus remains a mystery; after relaunching it, the problem no longer reappeared. I don't know if Sysinternal's Process Explorer would have revealed this, because WSL is no ordinary process, but in any case, I'm not an admin (except inside the Linux distro run by WSL), didn't want to spend my time figuring out whether I can install and run it without admin rights, and even if I could, would it have shown enough information to solve the problem.
So this is what I would recommend to anyone running into this problem: try to activate the focus-stealing UI with Alt + Space or with a context menu key. Then, start closing other visible apps one by one and keep using the app that you want to stay active; test after each closing if the problem persists. If you have closed all other visible apps and the problem is still there, then keep closing apps shown on systray. At some point you'll probably find your culprit.