Via a customer liaison, we received a problem report from a customer.
The customer is facing issues with delayed desponses to opening a .lnk file by pressing its keyboard shortcut hotkey. This delay does not appear when the shortcut is double-clicked.
For example, the customer has created a shortcut to Notepad and assigned it the shortcut Ctrl+Alt+X. Pressing the keyboard combination sometimes takes 5 or 6 seconds for Notepad to open. As noted above, double-clicking on the shortcut causes Notepad to open without delay.
This issue is not consistently reproducible, but it appears to be independent of the shortcut file itself. Any shortcut with a hotkey exhibits this problem.
All the shortcuts in question are on the desktop.
The short answer is “There is a program running on your machine that occasionally stops responding to messages. If you press a shortcut hotkey during those moments, you will experience this problem. Identify the program that stops responding to messages and fix it.”
Okay, that sort of cuts to the chase, but the interesting part is the journey, not the destination.
First, observe that if you associate a hotkey with a shortcut to say Notepad, and you press the hotkey twice, you do not get two copies of Notepad. The first time you press the hotkey, Notepad launches, but the second time you press the hotkey, focus is put on the existing copy of Notepad. This is one of those things that’s so natural you may not even realize that it’s happening.
When you press the hotkey assigned to a shortcut, Explorer receives the hotkey and needs to decide what to do about it. Before it can launch the shortcut, it needs to see if the shortcut target already has a window open, in which case it should just switch to that window.
Finding out whether a window has a hotkey is done by sending the window the WM_GETHOTKEY
message. When you press a hotkey that is assigned to a shortcut, Explorer goes to all the windows already on the screen and asks each one, “Hey, what’s your hotkey?” If any window says, “My hotkey is Ctrl+Alt+X,” then Explorer says, “Oh, sorry to step on your toes. The user pressed your hotkey, so here, go ahead and take focus.”
If no window cops to having Ctrl+Alt+X as its hotkey, Explorer says, “Okay, well, then I guess I have to make one.” It launches Notepad and tells it, “Oh, and your hotkey is Ctrl+Alt+X.”
If there is a window that is not responding to messages, then when Explorer asks it, “Hey, what’s your hotkey?”, the window just sits there and doesn’t answer. After about three seconds, Explorer gives up. “Yeesh, I was just asking a question. Don’t have to give me the silent treatment.”
And that petulant window is the source of the 3-second delay. It takes Explorer 3 seconds before it finally gives up and says, “Forget it. Even if that was somebody’s hotkey, they’re being a jerk, so I’m just going to pretend they didn’t have a hotkey. Let me open a new window instead and just deal with the hotkey conflict.”
0 comments