I have global Windows shortcut keys assigned to several different cmd.exe instances. I do this by creating shortcuts to cmd.exe on my desktop, and assigning each one a unique shortcut key (for example, CTRL + SHIFT + U). Pretty basic stuff. I'm using Win2K8 (R1 and R2).

This works just fine... most of the time. But with infuriating regularity, sometimes it doesn't. Or it will work with a long delay (many seconds). It doesn't matter what app currently has focus (it can even be one of the command prompts). It doesn't matter what keys I assign (I've tried a few variations of WIN, CTRL and SHIFT). I did notice that this is often, but not always, correlated with explorer.exe struggling in some way or another (say, an explorer window opened to a file share that's unavailable, or an app being unresponsive, or whatever). In other words the shortcut key handling appears to be very sensitive to unrelated system activity. Note that whenever I have this problem I can always successfully ALT + TAB to the window I want to get to, but that's tedious.

I use the shortcuts to these command windows hundreds of times a day so even a 1% failure rate becomes really annoying.

Is there a way to fix this, or is there some third-party utility out there that will RELIABLY intercept custom key combinations to bring focus to whatever apps I want, in a way that is independent of other system activity?

ADDENDUM:

There is a property of the Windows shortcuts that I would not want to lose if switching to a third-party hotkey tool: Windows shortcuts are idempotent. Once you've launched a shortcut to some app, pressing the shortcut key combo again takes you to the already launched process - it does not launch a new process.

6 Answers
6

Use Autohotkey. The scripting language is non standard and can be difficult to learn, but if all you're wanting to do is reliably launch programs, its simple. Plus you can base shortcuts off the Windows key! Use following sample script and modify it to your needs. (Lines starting with ; are comments.)

Save this as a .ahk file on your desktop, install autohotkey and run it.

Every time you press any key combination, AutoHotkey will scan this script. If it matches any of the key combinations that preceed a ::, it will execute the next command. If the return statement is missing, the AHK will continue to scan the script for matches after executing your statement. The key combinations are described below.

# = Windows Key
+ = Shift
^ = Control
! = Alt

You can use these in any combination with the letters of your keyboard. One combination I find extremely useful is as follows.

Autohotkey is basically its own programming language. I have scripts set up that simulate "Rocker Gestures" system wide. I have GMail like shortcuts for my email. If you spend the time to learn some of its tricks, you can get nuts with it. Lifehacker has a whole bunch of useful scripts for Autohotkey. Have Fun!

Hmm - an important feature of the Windows shortcut key that I rely on is its idempotency. The first time I hit CTRL + SHIFT + U to bring up a given prompt, it launches cmd.exe. The next time I hit that combo, if that cmd.exe is still running, it simply brings it to the front, instead of launching another instance (which is what the Autohotkey run command does). Is there a way to easily do that with AHK?
– Peter BaerFeb 18 '10 at 19:25

You can change the title match mode to be as restrictive as you need. If I had another hotkey that matched on "Mozilla Firefox" (instead of "Super User", for example) it would cycle through all my Firefox instances, since each has that text in the window title and I have it set to match the text anywhere in the title.

How can this script be modified to NOT be idempotent? Specifically, I want multiple instances of a program if I press the shortcut keys (I'm running putty, and need to be able to connect to 4+ servers at any given time, and don't want to have to reach for the mouse)
– Doktor JFeb 17 '12 at 21:09

If there is specific, unique text in the window title for each instance, you can assign hotkeys to match that text. See the Caps+a and Caps+s above for two different instances of firefox, @DoktorJ
– yhw42Feb 18 '12 at 1:52

But what if I never want it to match? When I'm switching between them, I just ALT+TAB, so I don't need shortcuts for each instance of PuTTY -- I just need a shortcut that always opens a new instance of PuTTY, no matter how many PuTTY windows I already have open. Will just calling "run c:\tools\putty\putty.exe" directly from the assigned hotkey do this?
– Doktor JFeb 18 '12 at 15:06

@DoktorJ: Oh! Yes. That's exactly how you'd do it. Though I think you can assign hotkeys in the Windows shortcut properties as well. I had assumed you meant to have Caps+1 point to a specific instance of PuTTY (which is better than AltTab in my opinion :) ).
– yhw42Feb 18 '12 at 15:38

@Tyr: it does. I started using that in Windows XP, but continue to do so in Win7. I haven't used the start menu search very much, but my impression is that Launchy is still faster. I may be wrong on that though.
– GauthierMar 19 '12 at 15:18

Unfortunately 6 years later with Windows 10 the same issues exist, and with a recent Windows 10 update I found that some shortcuts/programs are no longer
idempotent! Especially Putty where I have multiple shortcuts for the same session.

So I use AutoHotKey and modified the function shared in this thread (based on this article at LifeHacker) so that it uses an INI file to keep track of each shortcut. This does not use the Windows Title of each program as that can change in Putty if you use screen or SSH into another server, a feature I personally want to keep!

Also included is a function "DeleteINIEntry()" which you can create a shortcut for to have it remove an UniqueName entry from the INI file. Or you can just manually edit and change the file.

This is a free utility that allows you
to define your own hotkeys so that a
single key press can launch an
application, insert commonly used
text, change your audio volume, or
just about anything else. The program
requires Win95/98/ME or WinNT/2000/XP,
and is an excellent performer even on
slow machines. PS Hot Launch is the
perfect alternative to the Start menu
and the Quick Launch panel.