Microsoft Windows and the Keyboard Focus

There is an issue with MS Windows that has really been bothering me for a while and I was wondering if anyone knew how to fix it. It is so annoying that I was originally going to create a Pit thread to lament, but in the end I would prefer a solution over a venting. In Windows, there is a concept called keyboard focus. Roughly it means that one window (program) has the keyboard focus and each key that you type is sent to that window. Various events will cause Windows to give the focus to other windows. For example, when you start a new program it will automatically get the focus. Likewise when you click on another application or Alt-Tab.

The problem is, there are plenty of unexpected events that occur to change the focus: an IM arrives, a program running in the background pops up a message, a slow program finally starts up, etc. This doesn’t present a problem if you are typing slowly and looking at the screen, but it can be down-right dangerous otherwise; particularly since keys like RETURN and SPACEBAR can execute a command or close the new window. I can’t count how many times I’ve been busy typing away when a message box pops up, steals the foucs, and before I can react, gets closed by my errant RETURN. Other potential disasters are lurking as well. Imagine your entering a password and you get a IM from your mortal enemy. Before you realize it, you enter your password and hit return. Your mortal enemy would have instant access to your collection of erotic Transformers pictures.

I realize that there are plenty of “legitimate” reasons why the focus should be automatically changed - an application with multiple windows may want to automatically pass the focus around. Really all that is needed is to prevent the focus from automatically changing processes. So is there a fix or a work-around for this issue? There is an option in TweakUI that sounds like it would disable this, but it didn’t seem to pan out.

Paste this into “Start, Run” and run it. This is the setting TweakUI should be adjusting.


reg add "HKCU\Control Panel\Desktop" /v ForegroundLockTimeout /t REG_DWORD /d 0x00030d40 /f

You’re right; that is the setting that TweakUI sets and I have it on my machine, but it still doesn’t block all of the pop-ups that I get. I wonder if that setting doesn’t apply to MessageBox? In any case, thanks for the registry entry. I did not know that that was what is set and I certainly didn’t realize that it was configurable in milliseconds.

As this is IMO certainly a Pittable offense by any writer of software, I have plenty of comments.

This isn’t the pit though, so I’ll keep them to myself.

I, like the OP, have certainly sent things via IM that I wouldn’t have wanted to due to this exact issue.