Create your own shortcut keys with Autohotkey (tutorial)

How will you open your Web browser? Are you using a Desktop shortcut? You don't need to. You can simply assign keys to do whatever you need. You can assign alt + C to open Chrome browser or you can set that combination to open your Movies folder or to shutdown your pc.

create your own shortcut keys with autohotkey

AutoHotkey is a small handy utility used to create Hotkeys for anything that we would like to do in our pc from creating shortcut keys to open programs to Muting your speaker with a single keystroke. It can be used to do some cool things like creating multimedia keys (if your keyboard don't have any), remapping keys (making a key to work as another key) it would be useful if you have damaged any important keys in your keyboard. So, in this post I will explain you how to use AutoHotkey in a productive way.

  1. First, You must have installed AutoHotkey in your pc. Download AutoHotkey.
  2. After installing it, right click anywhere in your desktop or in Windows Explorer.
  3. Then select New and then AutoHotkey script.
  4. Name that file and open it using notepad. Delete any existing codes in the newly created AutoHotKey script.
  5. Now, you are all set to use this utility. Just copy paste and save some of the codes given below into that notepad file. save and run (Double click) that notepad file.
  6. By using the respected keys check how it's working. Before running every code don't forget to read the descriptions.

Hotkey is a key or combination of keys used to trigger some actions in our pc. To use AutoHotkey you need to know howto represent keyboard keys as a hotkey in this software. Ctrl,Shift and Alt keys are called as modifier keys. To use these keys as a hotkey we must represent those keys as follows,

KeyAutoHotkey representation
Control^
Alt!
Shift+
Windows Key#

Note: Don't use separate notepad files for each codes you can use single file for all of your favourite codes.

Hotkeys set by you will work until you close the script. To close the script right click the green AutoHotkey iconin the notification area and select Exit.

The combination keys before two colons could be replaced by the hotkeys you prefer. Remember one thing you can use a single key in place of those combination keys you want and this is not recommended as the actions will be executed with single keystrokes. Still, you can replace it with a single key. I assume you won't use Insert key often so, you can use that kind of keys.

To create shortcut keys

Yes, you can use this utility to make shortcuts keys not only for your favourite programs but also for the folders frequently accessed by you. Just check the following codes.

^+c:: run chrome
^+m:: run D:/Movies

Enter your hotkey followed by two colons and a space. Now type run followed by the program you want to run. To find the name of your program simply right click the desktop icon of that program and select properties. In target dialog box you can see your program's name.

Eg: " C:\Program Files\Mozilla Firefox\firefox.exe "
Just type firefox after run to create a shortcut key for firefox.

If you want to open a specific folder/file type the path of that folder/file instead of software name. To find the path of the specific file/folder right click that file and select properties. Under general tab, after location you could find the complete path of that file. Just copy paste that into your script. That's all.

To create Multimedia keys

Do you want to turn off you speakers with a single press? Obviously, you can do it with AutoHotkey. All you have to do is insert some simple codes into your script file. That's all. You're all done.

^+u::send {Volume_Up}
^+d::send {Volume_Down}
^+m::send {Volume_Mute}

Using this code, You could increase the volume by pressing Ctrl + Shift + U and decrease the volume bypressing Ctrl + Shift + D and you can even mute the speakers by pressing Ctrl + Shift + M.

Eliminate holding shift

Programmers may find it difficult to hold shift while they code programs. A single script in AutoHotkey can solve that problem too. Check the following code

1::!
3::#
7::&

The above code will replace 1 with "!" 3 with "#" and 7 with "&" number keys mentioned here are the one above your qwerty keys and this wouldn't affect your numpad number keys.

Texts manipulation and signature

::afaik::as far as I know

By using the above code, whenever you type "afaik" and a space it will be replaced by "as far as I know". Edit the above code and create one as per your needs.

^+s:: Send Regards,{Enter}Ganapathy Vignesh

This one can be used to put your signature by pressing Ctrl + Shift + S. Here the text marked with yellow is replacable and "{Enter}" is used to automate the press of Enter key.

Shutdown, Logoff shortcuts

^#s:: Shutdown, 0

The code above can be used to logoff your system when you press Ctrl + WindowsKey + S. Use 1 instead to shutdown and 2 to restart.

Always on top

^SPACE:: Winset, Alwaysontop, , A

What'll you do when you want to watch a video and browse the web simultaneously. If you select one window, the other one will disappear to prevent this use the above code. Select the window you want to be on top and press Ctrl + Space. Now, it'll be on top until you press Ctrl + space after selecting that window. This trick was taken from the world's famous tech blog labnol.

Set your numlock be always ON

SetNumLockState, AlwaysOn
setCapsLockState, AlwaysOff

You can use AutoHotkey to set your num/caps lock key state. If you use the first code in your script numlock will be set to always ON. You can't OFF it until you stop the script. Second code will set your capslock OFF. You can't ON it either, until you stop the script.

Make everything portable

If you are familiar with the shortcut keys, you can make it portable by compiling the script you run. Just right click the script and select compile script that's all. One .exe file will be generated by this action. You can use that .exe file in others pc without installing AutoHotkey. Check this one I have created a .exe file to select multiple files without holding ctrl.

Autorun it!

You need to rerun the script or .exe file after every restart to use the hotkeys. I know You'd not want to rerun the script after every restart. So, autostarting your script would be a better option. To autostart your script create shortcut (Right click → Create shortcut) of your script and move it into your windows statup folder. You can access starup folder by selecting start → all programs → startup. Don't search for startup it won't showup.

Some random tips

Do you hate the H icon in the notifications area? No problem you can remove it by adding #NoTrayIcon to the top of your script file. After adding that code that green H icon will disappear. You can assign a hotkey to even quit your script. Use the following code.

^+e:: ExitApp

If you can't quit your script by any explicit methods close it by opening your taskmanager. You must end AutoHotkey.exe process to quit the script.

You can create similar codes by reading the tutorial file provided with AutoHotkey. To access it right click the AutoHotkey icon in the notificationbar and click help while you run any script.

I hope you like this utility and use it everyday. If you find this useful please share this article on your favourite social network. If you have any doubts regarding this utility let me know with your comment....