Kulture Konnect Blog

Take the Tedium Out of Work With AutoHotkey!

Posted by Kents Herrero on Aug 11, 2016 9:00:00 AM


AutoHotkey, you say? What is it?

I'm glad you asked, humble reader! AutoHotkey in its core, is basically a scripting language that was made mainly for the creation of keyboard shortcuts and other macro-related tasks; which in turn allows for the automation of tedious tasks on almost any Windows application!


Why do I need to use it?

Apart from feeling like a keyboard ninja? This handy little tool can make your life at work easier by shortening monotonous tasks or sometimes even completely eliminating them! It can launch programs, open documents, emulate keystrokes and mouse actions.

These commands are triggered by pressing a key or sequence of keys on your keyboard. For example, you can create a script that automatically opens five application that you always open every time you start your day at work: So instead of double-clicking five icons you can just press say, [Windows] + [F1] and all your desired applications will open, awesome right?

The fun doesn't stop there! It can also be used to replace strings as you type them- also known as hotstrings- so for example, if you compose a lot of emails, you can type btw and it will magically transform into by the way; or say you have 3 different signatures, you can just type sig1, sig2, or sig3 and voila, the signature of your choice is summoned forth!

Also, keys on the keyboard can also be remapped, such that pressing [CapsLock] will instead send a [Backspace], for example.

Other tasks that can be done with AutoHotkey include the following:

  • Controlling the mouse with the keyboard or joystick.
  • Opening programs, links to websites, or even searching in Google.
  • Filling in forms automatically.
  • Displaying text on screen.
  • Manipulating windows.

New Call-to-action


This is all so good and great! So how do I get started?

Easy! First you must go to AutoHotkey's download page and well- download it! You may also use the portable version but if you don't have any specific reason for using it, I suggest going with the installer version, as it comes with its own compiler and help file.


Once installed, you can create a file with the .ahk extension which is just a text file and paste the following lines of code below.

DetectHiddenWindows, On


Run notepad
Run cmd
Run http://www.google.com/search?q=cute`%20kittens

::btw::by the way
::Btw::By the way



#Esc::WinKill, %A_ScriptDir%\%A_ScriptName% ahk_class AutoHotkey

Now hold onto your horses! I'll be explaining these arcane pieces of text in a jiffy.You may first confirm if it's working if you didn't receive any error and you see a new icon happily waiting for your attention in your notification bar.


Now to go through the script and find out what it can do...

The line DetectHiddenWindows, On allows the script to detect hidden windows which is required by some commands of AutoHotkey, in our case- the last command in the script: Let's leave this line here and let it do it's magic as it doesn't interest us right now.

The #F5::Reload line is a hotkey. Basically, it makes pressing [Windows + F5] do a Reload command, which restarts the script! This basically lets us easily test our changes when editing the script by pressing the corresponding keys after saving the file! Lovely.

How is it [Windows + F5] you ask? Well, on the left side of the pair of colons,  the # character stands for the [Window] key. Other modifier keys are represented by other symbols as shown below:

!  Alt
^  Ctrl
+  Shift

Now onto the third statement:

Run notepad
Run cmd
Run http://www.google.com/search?q=cute`%20kittens

This is essentially a group of commands stuffed into one hotkey. By pressing [Windows + F1], you are commanding the script to run notepad, command prompt and a web browser doing a search for "cute kittens" on google! The Return line is used for hotkeys that spans multiple lines such as this example, it basically tells the hotkey to stop executing the commands found on the following lines. If we forgot to put this in, pressing the hotkey would execute all the commands under that #F1:: line, including commands from other hotkeys below it, until a Return is encountered! Which is a good way to get unwanted behavior. Basically, if your hotkey spans multiple lines, always put a Return at the end. Single-line commands like the #F5::Reload one don't need a Return statement.

The fourth statement- ::btw::by the way- is a hotstring! The difference lies in the first two colons before btw, which tells the script its a hotstring. To execute this, you must type what comes between the two pairs of colons, in this case, btw. Do it now and watch as what you just typed magically expands into "by the way"!

The fifth statement is basically just a copy of the fourth, but this time the letters for both the triggering string and the expanding string is capitalized. Which is useful for when using the hotstring at the beginning of a sentence.

The sixth, #F9::Suspend basically allows you to toggle the script between paused and unpaused. This allows you to disable and enable the script at your leisure. You will be needing this for the next commands!

The seventh and eight statement are remappings. Pressing p will "send" an o and vice versa. To temporarily disable this possibly annoying behavior, just use the last command [Windows + F9]! Keep in mind that this will cause the whole script to pause!

The next and last statement is a little more complicated than the previous ones so pay attention!

By pressing [Windows + Esc], this script will close itself! How, you ask? It uses its WinKill function and references itself with %A_ScriptDir%\%A_ScriptName%, which are AutoHotkey's own global variables, and makes sure the referenced file is an AutoHotkey process with the ahk_class AutoHotkey part. Note: the WinKill function is the one that requires the DetectHiddenWindows, On part to be able to close itself, since the script doesn't have its own window- it's a "hidden window".

This complex part, along with everything else you may be wondering about is better explained in detail in AutoHotkey's very own help file! One way of accessing this treasure trove of information is by opening a script, right-clicking its icon in the notification bar and and selecting "Help".

There are a ton of resources out there to help you get started in becoming an AutoHotkey pro! Here is one "little" script that takes the "auto-correct" feature in your smartphones and tablets, and puts it on your desktop. Just run it and watch as you become a lazy keyboard smasher! Type "omlette" to see it in action.

That's a lot of stuff isn't it? But we've just scratched the surface of the AutoHotkey world. Learning the rest is easy and depending on your needs, might actually be unnecessary. With what you've learned so far you should be able to create simple little scripts tailored to your tasks. Hopefully I've explained just enough to get you started! Already using AutoHotkey you say? Share your scripts and let us know how this awesome tool has helped you in the comments below!

New Call-to-action

Topics: Print & Web Design, ProTips


We’ve created this blog for entrepreneurs, restaurateurs, marketers and designers who want to dig deeper into branding, marketing and design. Our aim is to provide great advice on the latest industry trends and offer you some educational tools that will help improve your bottom line.

We'll be sure to show you lots of great examples of best practices in the graphic design and marketing world, but we also like to have fun around here, so be prepared for the occasional whimsical post to brighten your day.

Sign up to join our mailing list and feel free to connect with us any time!

 Kulture Konnect is a one-stop marketing and graphic design studio assisting over 45 small, medium and large size businesses. We specialize in branding, web design and content marketing. Kulture Konnect aims to help its customers create and implement graphic design and marketing that people actually love.


Subscribe to Email Updates

Recent Posts

Follow Us