There are unrelated software that can help you. Because nobody really wants to know what's the active window at the moment, this feature is rarely seen in applications. Except, if you do some kind of time tracking.
2 services: Paymo3 and Timecamp, have an option of tracking the time you spend working on the PC, for billing reasons. The PaymoPlus app records active windows, and time on them, so you could then add them to specific tasks, so you can bill the client. Timecamp does the same, but automatically adds the apps to a task.
The thing is - you can see when and what apps were focused at any given time, which is what you need. Run the app, start the timer, do your stuff while waiting for this glitch to happen, then, either look in the PaymoPlus window if you're using it, or on Timecamp web UI, if you're using that one.
I'd go with PaymoPlus. http://www.paymoapp.com/