Pressing a registered hotkey gives you the foreground activation love

Raymond Chen

One category of application that people complained about is the application launcher which keys off a hotkey and doesn’t get the foreground love.

Well, except that windows with registered hotkeys do get the foreground love.

After you call the RegisterHotKey function to register a hotkey, the window manager will send you a WM_HOTKEY message when the user presses that hotkey, and along with it, you will get the foreground love. If you call SetForegroundWindow from inside your hotkey handler, the foreground window will change according to your instructions.

A special administrator-only list of programs which are exempt from SetForegroundWindow rules would just be adding another round to the game of walls and ladders. All that’ll happen is that programs, when they install, will place themselves in the Exempt from the normal rules list, and you’re back where you started.

“Oh no, I’ll super-protect that registry key so that the only way to add an entry to it requires a human being to respond to a dialog box confirming that the entry is being added.”

Well, for one thing, that doesn’t actually stop installers with administrator privilege, since they can just remove the super-protection and update the key anyway. (Administrator privilege is like that.) And even if you somehow manage to super-protect the setting (how? beats me), the next stage is application vendors (or system administrators attempting to deploy the application across their company) asking for a programmatic way to add their program to your super-protected list of exemptions. And then you’re back to where you were.


Discussion is closed.

Feedback usabilla icon