Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Windows (XP, 7, 8) how do you quickly assign keyboard shortcuts to launch your favorite applications using autohotkey when the application is active.

In Keyboard utilities, you can launch your favorite applications for fast access, by simply pressing a hotkey.

I was wandering if that could be done using autohotkey as well.


Normally to add a script that when Ctrl+Alt+N is pressed, Notepad will be launched. You would need to have the following script.

^!n:: Run Notepad

What I want is that when the application is active, pressing Ctrl + Shift + A should take the path where the application is installed and create a script like above.

So when Command Prompt is active, pressing Ctrl + Shift + A should create a script like the following.

^!t:: Run C:\WINDOWS\system32\cmd.exe

where C:\WINDOWS\system32\cmd.exe is the path where cmd is installed/located

and Ctrl + Shift + T is the keyboard shortcut.

share|improve this question
Yes, it is windows (XP, 7, 8) – Ishan Dec 27 '12 at 22:37
Added it to the question ;) – Everett Dec 27 '12 at 23:01

This isn't something you can do easily.

You could do something like:

Or you could modify your file at runtime and reload it.

#SingleInstance Force
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

    WinGet, pn, ProcessName, A
    path := GetProcessPath(pn)
    tooltip, press a new hotkey
    Input, new_hotkey, L1

    code = ^!%new_hotkey%`:`:Run, %path%`n
    FileAppend, %code%, %A_ScriptFullPath%

    Sleep 1000 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.
    MsgBox, 4,, The script could not be reloaded. Would you like to open it for editing?
    IfMsgBox, Yes, Edit

GetProcessPath(exe) {
    for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process where name ='" exe "'")
        return process.ExecutablePath


^!f::Run, C:\Program Files\Mozilla Firefox\firefox.exe
share|improve this answer

Yes, you can. The following example will launch explorer when Win+0 is pressed (# denotes the Window key in AHK):

#0::Run C:\Windows\System32\explorer.exe

If the application does not launch because it is already running, you could create a batch file containing:

start program.exe

And tell the AHK script to launch that batch file.

share|improve this answer
I already knew how to do that but this is not what I am after. Your solution requires to actually find the application path and then create a keyboard shortcuts from it. Please have a look at the to illustrate what I am after but using autohotkey instead of PhraseExpander which the video uses. – Ishan Dec 27 '12 at 3:35
So you're after a GUI to create shortcut assignments? – Suchipi Dec 27 '12 at 20:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .