Iris Classon
Iris Classon - In Love with Code

Stupid Question 188-193: What is AutoHotKey, macros, automation software, hotkeys and scripts?

[To celebrate my first year of programming I will ask a ‘stupid’ questions daily on my blog for a year, to make sure I learn at least 365 new things during my second year as a developer]

Me on stage at DevSum 2013

The day before my session at DevSum I decided to throw away my slides and do code only. Usually you don’t want to do that (change a session the day before) but I felt confident in the topic and I manged to get in several practice runs dry runs with the new session before getting ‘on stage’. The session was about Windows Store Apps, and I was creating two identical apps, one with C# and XAML and the other one with JavaScript and HTML. I had to problems:

  1. I needed to use pre-made code (snippets) to cover all the concepts in less than 50 minutes
  2. To better compare the two implementations I wanted to also compare just the code snippets in another editor (sublime)

Two weeks ago me and John Sonmez did a podcast with John Papa on Get Up And Code! And he talked about his Pluralsight course on public speaking, I had watched it and he had talked about a tool called AutoHotKey – which he recommended for code snippets as it wasn’t editor specific.


Nothing new, but the first time I actually realized how much simpler my life could be with macros. And now I want to share this with you. Let’s define some words:

Basically the same as shortcut keys, keys that when combined in a certain combination leads to a certain action. Such as Window + D gives you the desktop, and Windows + P second screen options.

Automation software
Software that makes systems self-acting and/or self-regulatory.

Stupid Question 71: What is a scripting language?

Something that should happen

Predefined actions (scripts) that is run when you want. These are often used to simplify repetitive tasks, and benefits of macros are:

  • • Reliable (same set of actions, nothing is forgotten)

  • • Less manual work (time saving)

  • • Fast (speed)

  • • Sharable actions (macros and scripts can be shared)

A windows keyboard macro program- or as they say:
“Fast scriptable desktop automation with hotkeys”

Records your actions and saves them as a macro so you can reply those actions. Excellent for long macros.

So we have the words down now, and basically all you need to know is that:

a. You can tell your computer what to do by writing a script or several
b. Scripts for one particular action/result/goal is called a macro
c. You can call these macros by using shortcut keys, also referred to as hot keys
d. AuoHotKey is a program that allows you to create macros for Windows
e. It is VERY simple, and AWESOME

To get started, download AutoHotKey at their site

Here are the steps for your very first script (courtesy of AutoHotKey):

  1. Download and install AutoHotkey.
  2. Right-click an empty spot on your desktop or in a folder of your choice.
  3. In the menu that appears, select New -> AutoHotkey Script. (Alternatively, select New -> Text Document.)
  4. Type a name for the file, ensuring that it ends in .ahk. For example: Test.ahk
  5. Right-click the file and choose Edit Script.
  6. On a new blank line, type the following: #space::Run

The documentation they have is really good, with an active forum with plenty of pre-made scripts!
I have four scripts that I’ve made and use a lot:

  1. A script for each my sessions that opens all the programs and files and projects I need for a session (slides, code project etc). It also sets up my environment (closes Skype and so on).It also runs a script that creates shortcuts to all my code snippets (see below) for that demo, as well as a backup so I fast can get to a working project if something gets messed up.

  2. .Scripts with code snippets

  3. Email scripts with pre-defined email replies that I can also use in any email client, or any other communication channels. The replies pastes in the recipient’s name.

  4. I’ve disabled my CapsLock button and you need to hold down Ctrl to enable it

Keep in mind I’ve only used this tool for a few days, and this is my first experience with Macros, so I bet I’ll come up with some more cool and complex stuff :D I made a simple app (it’s not done yet) for family members so they can use this tool as well even though they aren’t into programming/scripting at all :) – but I bet I can get them into it ;)

Nothing like a simple UI to get my family members started with macros - and looks like auto-correct feature would be nice LOL :D

Here is the script for email snippets that inserts copied text:

[sourcecode language=“javascript”]

SendMode Input
SetWorkingDir %A_ScriptDir%

clipboardBefore = %clipboard%
Send ^x
Sleep, 100

ClipBoard = Hi %clipboardBefore%, I’m current out of office. rn
Send ^v
Sleep, 100
clipboard = %clipboardBefore%


In case you are wondering what is happening in that script:

The script explained

And here is the disable Caps Lock one:

[sourcecode language=“javascript”]

SendMode Input
SetWorkingDir %A_ScriptDir%



There are several cool things you can do, and here are some popular scripts from the site These are some very simple get started scripts, such as:

  • Poor man’s SnagIt

  • Make window transparent on key press

  • Move window from the left monitor to the right monitor and other way around

  • Middle mouse button in combination with mouse wheel scrolling activates Alt-Tab (down) andShift-Alt-Tab (up)

  • Look up selected text in google

I’ll write up a longer blog post about advanced scenarios – this was more of an introduction, and I’ll make sure to publish the app somewhere on the blog.
I’ve also scheduled a blog post on AutoScriptWriter, so keep an eye on this site ;)
And please share what your best macros, bragging is very welcome,- I love hearing about cool stuff- and so does everybody reading this blog :D


Leave a comment (via email)

Last modified on 2013-06-01