Tag Archives: macros

Using AutoHotKey macros to make typing – and life – easier

What things do you regularly type, over and over again? I’ll bet you’ve answered your name, email address, or your username(s) on sites you use regularly. Maybe also your postal address, phone number, or your job title and organisation.

For years, I’ve used a handy free windows app called AllChars, to type these things — and more — for me. For instance, I’d type /am, and it would magically change that to Andy Mabbett

12 Màquina d'escriure Underwood

You can’t use macros to paste text on one of these

I’d often use it, to type very long and complex template markup in Wikipedia:

<ref name="">{{Cite episode |title= |series= |serieslink= |url= |accessdate= 2014- |network= |station= |date= |season= |seriesno= |number= |transcript= |transcripturl= }}</ref>

which I could then populate with the relevant values.

Unfortunately, AllChars is extremely buggy under Windows 7 and subsequent operating systems; so much so that I found it unusable on both my parents’ laptop, and the shiny new machine I use in my recently-begun role as Wikimedian in Residence at the The Royal Society of Chemistry. (The Society has a very reasonable policy when it comes to allowing technically-literate staff to install software, licences permitting. Others take note!)

I’ve been looking for a replacement, and am absolutely delighted to have found AutoHotKey, which is easily configured to paste macros just like AllChars, and has many more features besides. Better still, it’s not merely free, it’s open source.

Here’s what I learned, in setting it up:

AutoHotKey uses scripts, one of which is loaded by default, and others can be loaded as required (say, just for writing about the taxonomic names of plants).

To make it type my name, I edited the script and added a line:

::am::Andy Mabbett

which is the most basic configuration. The two sets of colons are delimiters, and am is the string to be replaced. The replacement doesn’t occur until the user types a space, tab or return. I prefer to override that, making use of another feature, which is to add an asterisk after the first colon:

:*:am::Andy Mabbett

so that the string is typed without the space, tab or return — again mimicking AllChars’ behaviour.

Using that macro, however, interferes with typing words like “amicable”. Because all my AllChars macros began with \, and I have invested a lot of muscle-memory in them, I’m keeping that:

:*:\am::Andy Mabbett

so now I have a macro which works just like one in AllChars, and lets me type “amicable” without it triggering.

Another thing I learned is that some characters need to be escaped, using curly brackets (or “braces”). For example a hash:

:#:/fb::{#}fb

which types #fb

and even curly brackets themselves:

:*:\ac::{{}{{}Authority control{}}{}}

which types {{Authority control}}.

Line breaks are made using:

{enter}

I found these things by using the official AutoHotKey forum, where the users seem knowledgeable and helpful — my first query was answered promptly and effectively.

Once I’d worked all that out, it only took a few seconds find-and-replacing, and I had converted over 220 (yes, I was surprised, when I counted them!) macros from AllChars to AutoHotKey.

However, AutoHotKey isn’t only for pasting texts. It can be configured to carry out more complex tasks, such as opening and closing applications or windows, copying text from one and pasting it to another, and so on. I’m looking forward to learning more abut how to do that, and investigating the pre-written scripts provided by members of the AutoHotKey community.