What is Autohotkey?

Visualwebz
All About Programming Languages
6 min readJan 9, 2021

AutoHotkey and shortcuts, in general, are a great way to save time in your daily work.

You might be using a simpler form of AutoHotkey (AHK) and don’t even know it. You might already be using hotkeys and keyboard shortcuts on your computer. Keyboard shortcuts such as Ctrl-C to copy and Ctrl-Alt-Delete are one of the many common uses for shortcuts. These shortcuts are implemented in windows and usually perform straightforward tasks. But you can go a step up with AHK and up your productivity!

https://www.autohotkey.com/

AHK

AHK is an open-source scripting code that creates more complex shortcuts that are not available as default. For example, Macros are a sequence of key presses that can be initiated with one keypress.

History

It all began in 2003. According to the AutoHotkey foundation, AutoHotkey was first developed by a guy named Chris Mallett. After Chriss Mallett lost interest in developing AHK, Steve Gray, AKA “Lexikos,” picked up the pieces and began developing it himself in 2009; his work will result in the version called AHK_L being released. At the same time, Chris Mallet’s version was AHK v1.0.48.05. In 2011 Gray looked into making another version of AHK, called “AutoHotkey v2-alpha”.

Things got a little complicated in 2012 as Chris Mallet still owned the autohotkey.com domain and decided to give ownership to A Ahmed, known as “Titan” or “Polyethene.” Ahmed chose to use his power of ownership to make Chris Mallet’s AHK v1 the official version of AHK. Since Steve Gray had been creating a community around his understanding of AHK_L for a couple of years, it created a lot of conflict between the two versions of AHK. A petition was made, and AHK_L became the official version of the domain.

As time went on, the website soon became a buggy mess, and a person named Charlie Simmons decided to create a website free of bugs. AHKscript.org was made in 2013, and that’s where many of the community migrated from the original site of Autohotkey.com. This new website was formatted in a different way than the original.

Finally, in 2014, Ahmed agreed to transfer the domain ownership of autohotkey.com to Charlie Simmons, who became the co-owner, and ironically, Ahmed was demoted.

To this day, the website is known as autohotkey.com, supported by a legal foundation (AutoHotkey Foundation LLC) to protect this script's legal and finance side.

Platforms

All this talk of AHK, but what exactly is it? As the AutoHotkey Foundation describes it, it is an open-source scripting language that creates hotkeys/shortcuts that would make life easier for any professional that uses multiple keystrokes. For example, digital professionals, graphic designers, web developers, CAD designers, web designers, even SEO and online marketers, to name a few.

According to the AutoHotkey forums, AHK runs strictly on windows. AHK commands use windows specific keys such as the window key.

According to Charlie Simmons, he responded to a forum post saying, “there are numerous platform-independent scripting languages. None of them can do specific things as well as a platform-specific scripting language.

Pro vs. Cons

AHK is a very functional and valuable software scripting language, but every upside has its downside. Slant. co reviewed AHK and stated the pros and cons of using this scripting language. According to Slant.co, AHK is very easy to comprehend and learn.

Since AHK is open source, many tutorials and guides are provided on their website. Example codes are in the libraries, and some forums assist anyone who needs it.

Not only is AHK so easy to use, but it’s also fully programmable. Shortcuts can be created with a couple of lines of code. AHK is very simple to use. It gives the user functionality to remap their keyboard layout to anything they want fully. Instead of using a “QWERTY” keyboard layout, AHK can allow you to remap it into “AZERTY.” I would question your choices because unless you can swap your keycaps, typing with a different keyboard layout using the standard one is a little bit weird.

With the syntax of AHK, macros and shortcuts are easily created and provide a wide variety of usefulness. According to a review on AHK, it works very well on different windows programs. This can be very helpful in filling out forms with a press of a button. Games can be much easier with macros, so repetitive actions can be defined by one key. AHK is very helpful when making macro dedicated keys. Macros can be assigned to lesser used keys to provide a better work and gaming experience.

Cons for AHK is that it is said that the syntax is very “primitive.” Its functionality is very limited to only windows.

How to code AHK

It is easy to get started with AHK because of the wide variety of libraries, but sometimes it may get pretty difficult to understand. To help provide a better understanding of AHK, there will be an explanation of a couple of main ideas for using this scripting language. Before getting in, AHK is a scripting language, which means it doesn’t need to be compiled but rather interpreted.

How would you start coding shortcuts for your computer?

First of all, to start, AHK provides downloadable files on their website to get created. There are many guides to help start coding in AHK. The best way to start first is to learn how to run code on AHK. AHK stated a plain text file with a .ahk file name and can run its code.

#w: : Run Chrome

Return

This example of how the syntax of AHK works. “#” is represented as the windows key in AHK. Once Windows-W is pressed, Chrome will pop up and run. This is a simple line of code that created a shortcut to open chrome. Creating shortcuts isn’t the only thing AHK can do. It can remap keys too!

OrginKey :: DestinationKey

w::i

a ::j

s::k

d;;l

return

The code above is an example of how to remap keys on AHK. This can be helpful if you are left-handed and need to use the left side of the keyboard when gaming. The syntax of remapping keys is straightforward. It is the original key followed by two colons and then the new key you want to remap. Another helpful feature with AHK is that your mouse can also be remapped too.

RButton::p

LBuuton::o

return

Mouse remapping is very useful when your mouse buttons aren’t working, or you have different preferences. Key remapping can get very complex if you dive deeper into the AHK guides with many other options to create the best layout for you. But if you’re a gamer, macros are the most exciting part of AHK.

1 ::

Send 1

Send r

This is one example of many macros that can be created within AHK. The first line of code assigns “1” with the macro. Once “1” is pressed, “1” will be pressed, and the “r” will be pressed. For a gamer, this can be a very functional macro. Macros can get much more complicated than this. AHK has a list of special keys and what they equate to. For example, “!” represented the Alt button. This is done because some keys have two possible outputs (ex 2 and @), while special keys such as Alt have no output. AHK can also be more complex in its code and include things such as loops

1::

Loop {

Send LButton

}

Loops have a straightforward syntax, but they can run forever if not done correctly, like the example above. The code above presses the left mouse button infinitely since there is no condition to stop it. One common way to fix this problem with running loops is to use a condition nested inside the loop.

1::

Loop {

Send LButton

If(A_index > 10)

break

}

A couple of new ideas are introduced in the code above. A_index is a part of AHK’s syntax and is used to count the number of iterations the loop has been through. Using an if statement, the loop breaks after 10 iterations. “Break” ends the loop and prevents it from repeating forever.

These are some of many examples of what AHK can do. It can be effortless to use. AHK provides pages of guides in their libraries with even more descriptive ways to create your shortcuts. Things like opening files and sending messages can be done with a few commands.

Take away on AutoHotKey.

You may argue that keyboards enable computer professionals, users, and gamers to create quick keys. Yes, but there are limits, and you need to buy a specific keyboard. Due to its functionality, availability, and ease of use, AHK will be expected to be very relevant for specific users.

One problem that might emerge is its exposure and not many people have heard of it.

The syntax is straightforward to understand, and there are libraries to help you. It’s so easy to download and install. So why not give this simple tool a chance. I’m sure it will help your productivity!

--

--

Visualwebz
All About Programming Languages

A Seattle web design and online marketing agency that delivers high-end websites. A passion for web development and SEO.