Take the 2-minute tour ×

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
add comment

2 Answers

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 youtube.com/watch?v=GzcQbrkdvJU&feature=player_embedded 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
add comment

This isn't something you can do easily.

You could do something like: http://stackoverflow.com/questions/12851677/dynamically-create-autohotkey-hotkey-to-function-subroutine

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

#SingleInstance Force
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%

    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
add comment

Your Answer


