AutoHotKey – Custom Keyboard Shortcuts in Windows

Have you ever heard about AutoHotKey or tried to set up custom keyboard shortcuts to start applications or open files and folders in Windows?

10 Reasons Why You Should Switch From Windows To Linux

Linux has its own custom keyboard shortcut option to attach custom shortcuts to Program, File, and Folder. For windows, the story is a bit different; here, you don’t have any built-in option; instead, you have to take the help of applications like AutoHotKey.

In the future, I expect Microsoft will introduce this as a built-in feature in their operating system or at least integrate it with its powerful open-source tool PowerToys.

What is AutoHotKey

AutoHotKey (Automation HotKeys Scripting) in the name, you will get half of the answer, left we will explain. It is an open-source ultimate scripting language for windows. You can write small scripts (Ex: Keyboard Shortcuts) as you do in Linux. (Only Linux users can understand this pain)

How to Mount Windows NTFS Partition in Linux

Besides shortcut key, it’s a whole scripting language, able to create complex scripts to automate all kinds of tasks like form fillers, auto-clicking, macros, etc.

Download AutoHotKey

To download, browser their website, and go to the download page, two ways to use AutoHotKey in your system.

  1. AutoHotKey Installer: It will install the application on system level, recommeded to begineers.
  2. AutoHotKey Zip: Compressed file require to extract on safe place.

Both options do not require any extra steps. Once you are done, you can start writing custom keyboard shortcuts.

Special Syntax

Without Ctrl, Shift, or Alt, shortcut keys are like life without love. Back to the topic, to specify this modifier key, you need to take the help of special syntax.

Below I have listed some helpful syntax alternatives to those modifier keys.

Tab$Tab
Shift+
Ctrl^
Alt!
Win#

Create AutoHotKey Scripts

To start writing the script for shortcut keys, required to create a new file with an extension “ahk”. Two different ways to make this file.

1. Create using Context Menu

Go to the location where you want to create a script and right-click on the blank area to open the context menu of the windows file manager.

Then navigate to New -> AutoHotKey script to create a new script and rename it.

It will only be listed for the installer version. If you were using compressed zip, then follow the below method.

2. Renaming Extension

If you were using the zip version of AutoHotKey, this option would not be listed on the context menu. They need to create a custom new file and rename the extension with “ahk”.

To do so, you need to enable the show extension of unknown files from the “Folder” option.

Show hidden extension
Show hidden extension

You already did it; that’s some cool buddy is reading.

By default, “Hide extensions for known file types” will be checked; uncheck that checkbox to show the extension of all file types in your system.

Now navigate to New -> Text Document to create a new file and rename the extension from “txt” to “.ahk” in the end.

While saving the file, it may ask, “Are you sure to make changes”, click Ok.

Assign Keyboard Shortcut keys in AutoHotKey

With all in work, you can now start creating shortcut keys for Applications, Files, and Folders. You can easily open and run them with the help of shortcut keys.

Make sure to remember a few things listed below while creating the script.

  1. “::”: Double colon is as a separator between shortcut key and action need to perform.
  2. “Run”: It specify which action need to be taken after shortcut key is pressed.

Shortcut Key for Applications

Let us create a shortcut key for the common application that comes out of the box with windows. In this case, you will open a notepad using the "Ctrl+n" keyboard shortcut key.

For the "Ctrl" key, you need to use special syntax. Revisiting the top where we have already discussed a special syntax alternative to those keys. In this case, an alternative to "Ctrl" is "^", place the below code inside the script you created earlier, save and double-click it to open.

^n::Run, notepad.exe

Now let us pick the google chrome browser. To open with the shortcut key, using "Alt+c" use the below script.

!c::Run, chrome.exe

Shortcut Key for Files

I have created a new text file on my desktop, with the content “Hello World”. I need to show all of the content of that text document whenever I press "Ctrl+h".

In this case, you need to specify the relative location of that exact file with the file name (including extension).

^h::Run, C:\Users\<Username>\Desktop\file.txt

Replace <Username> with your system username.

Shortcut Key for Directories

Directory with full of images, videos, movies, or games. If you want to pop the content of those directories directly using a keyboard shortcut key, you can do that too.

In this case, I will pick the Windows directory inside C Local Disk; you can replace it with something else. The shortcut key I assign to open that directory is "Win+w".

#w::Run, C:\Windows

Replace “C:\Windows” with the relative location of your directory.

Including all Applications, Files, and Folders

Instead of creating a separate “ahk” file for each of these custom shortcut keys, you can include all of them in one single file by inserting each script in a new line.

^n::Run, notepad.exe
!c::Run, chrome.exe
^h::Run, C:\Users\<Username>\Desktop\file.txt
#w::Run, C:\Windows

Autostart Shortcut Keys

It’s useless if your shortcut keys are not working on the next system power-up. For this, you need to place all of the script files inside the system startup folder.

To do so, open Run windows using the "Win+r" shortcut key and write "shell:startup" to open Run windows. It will open the Startup folder; place all of your AutoHotKey script files inside this directory.

Autostart script
Autostart script

Final Thought

For Linux, they can easily set up shortcut keys for any application they want, can also create automation scripts using bash language. But for Windows users, things are pretty complicated for beginners.

AutoHotKey almost solves all problems specifically related to a shortcut key; in the future, if you want to know more commands or popular shortcuts of AutoHotkey, then comment down below.

Leave a Reply