Thursday, February 20, 2014

FocusMonitor Identifies Processes Stealing Focus

Recently I've been having issues with some process stealing focus from the application I'm working in.

Like I'll be in Visual Studio or Word or Waterfox (a 64-bit performance focused build of Firefox) and suddenly focus is swapped for a split second and whatever word I'm typing gets cut off or a button I'm clicking isn't.

I found a very helpful post by Matt Gertz from some years back where he provides some VB.NET code for an application that can monitor processes that steal focus from it. I'm more of a C# guy myself, so I've run with Matt's core logic and created a 32-bit C# application in Visual Studio 2010 which provides similar functionality. It will also let you copy the log info to the clipboard to paste wherever for further examination.




I call it FocusMonitor, and you can download the source code.





6 comments:

Anonymous said...

Thanks, this helped me to find out that 53xxPCApp.exe from Mitel was stealing focus :)

John Hall said...

Newbie question how do you compile the code and run it please?

John Hall said...

Newbie question. How do I turn source code into something I can run?

Darth Continent said...

John, once you expand the ZIP file, under FocusMonitor\bin\debug you'll find FocusMonitor.EXE which you can run directly (it's a compiled executable derived from the source code).

You also should be able to build your own EXE using a compiler like Microsoft Visual Studio 2010 or beyond, you can obtain their "Express" edition for free.

Justin said...

This looks just like what I need, but it throw exceptions for me, because I am on a 64-bit system. When I select focus on a 64-bit window (like Windows Explorer)I get an unhandled exception that "A 32 bit process cannot access modules of a 64-bit process". It still displays the info for any 32-bit window if I choose to continue. Any chance of getting a version that will fully work on my 64-bit win7 machine?

Darth Continent said...

Justin and all, here is a 64-bit build of FocusMonitor, you can run it directly. I've tested it on my Windows 7 64-bit system and it runs fine, but if you encounter any problems please post.