Windows – Reliable custom Windows shortcut keys

keyboard shortcutswindows

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.

Best Answer

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.)

;win + alt + e ... unload ipod
#!E::
   run d:\Downloads\Apps\deveject\eject ipod.bat
   return

;win + w ... launch winamp
#w::
    run c:\program files (x86)\winamp\winamp.exe
    return

;win + a ... launch AS400
#a::
    run C:\Program Files (x86)\IBM\Client Access\Emulator\Private\1.ws
    return

;win + Shift a ... launch AS400 Printer
#+a::
    run C:\Program Files (x86)\IBM\Client Access\Emulator\Private\3.ws
    return

;win + ctrl + Shift a ... launch 2nd AS400 
#^+a::
    run C:\Program Files (x86)\IBM\Client Access\Emulator\Private\2.ws
    return

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.

; ALT Backtick ... ctrl f4
!`::
    Loop, parse, RcvCtrlW, `,
    {
     IfWinActive %A_LoopField%
     {
        sendinput ^w
        Return
     }
    }
    sendinput ^{f4}
    return

; win Backtick ... alt f4
#`::
   sendinput !{f4}
   return   

This is Alt + ` and Win + `. When this script is running and I press alt + `, the script sends ctrl + F4. Win + ` becomes alt + F4.

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!

Related Question