Thursday 1 October 2020

Working more efficiently with AutoHotkey (part 1)

AutoHotkey has recently started making a notable difference to my computing life in that I can now, relatively simply, automate certain repetitive tasks and hence work more efficiently. AutoHotkey is a free, powerful tool for writing scripts that will run in any Windows application. It’s beginner-friendly, so previous coding experience is not required. I highly recommend this tool!

 



My attention had been drawn to AutoHotkey following the publication of an ITI Bulletin article about it by Richard Lackey MITI and two posts on his blog in which he explained the basics of AutoHotkey and listed AHK scripts useful to translators.

 

I find AutoHotkey intriguing also because I’ve always been fascinated by IntelliWebSearch, which is based on AHK scripts. What’s more, AutoHotkey hotstrings work exactly like the Autocorrect feature in memoQ, which I rely heavily on for those recurring long compound nouns in patent translations.

AutoHotkey can be downloaded from www.autohotkey.com. To write a script, you then create and run an .ahk file, which you can later edit in a simple Notepad programme whenever you wish to change or add to the script.

 

Text expanders

 
The most typical use of AutoHotkey is the creation of hotstrings to expand abbreviations into full text. To give a simple example, typing the string thx will automatically produce the following sentence: “Thank you for your email”. This is my script for it:

::thx::Thank you for your email.
 

When I type tn, the script will enter the word translation. Here’s the script: 

::tn::translation


When I type @@k, the script will enter my email address kontakt@hippe-heisler.de. Here’s the script:


:*:@@k::kontakt@hippe-heisler.de

 

(Note: Using the asterisk * means that an ending character, e.g. Space, ., or Enter, is not required to trigger the hotstring.)
 

 

Instant access to folders or websites
 

When I press the Ctrl key in combination with the dollar sign on my keyboard (i.e. Ctrl + Shift + 4), the script will instantly open my folder for the 2020-21 tax year. Here’s my script:
 

^$::                        
Run, C:\Users\User\Documents\Accountancy\Cash Books tax year 2020-21
Return

 

(Note that in AutoHotkey ^ stands for the Control key.)

 

To access TweetDeck, I first press the Alt Gr key and then the t key. Here’s my script:


<^>!t:: Run, https://tweetdeck.com/


To access Woxikon (a site for German synonyms), I press the Alt Gr key and then the d key. Here’s the script:
 

<^>!w:: Run, https://synonyme.woxikon.de/


(Note that in AutoHotkey <^>! stands for the Alt Gr key.)

 

Quick access to several folders, displayed in a pop-up menu
 

This is a slightly more complex script that enables me to access, in an instant, the folders which I (currently) visit most frequently, for which I simply have to press the Alt key and x. The folders will then be displayed in a pop-up menu (at the location of my cursor).

 


This is my script for it (which needs to be written into a separate AHK file, not the one already created for other AHK scripts!):


Menu, Folders, Add, &Downloads, !1
Menu, Folders, Add, &OneDrive, !2
Menu, Folders, Add, &Murgitroyd, !3
Menu, Folders, Add, &Terminology lists, !4
Menu, Folders, Add, &Patent translation, !5
Menu, Folders, Add, Temporary, !6

!x:: Menu, Folders, Show

!1:: Run, C:\Users\User\Downloads       
Return

!2:: Run, C:\Users\User\OneDrive
Return

!3:: Run, C:\Users\User\Documents\Clients\Murgitroyd
Return

!4:: Run, C:\Users\User\Documents\Terminology lists
Return

!5:: Run, C:\Users\User\Documents\Patent translation
Return

!6:: Run, C:\Users\User\Documents\Temporary
Return


(Note that in AutoHotkey ! stands for the Alt key.)

 

Adding the ampersand symbols (&) to the script above has the effect that I don’t even have to use the mouse to open any of the folders in the pop-up menu. Instead, when I open the pop-up menu (by using Alt + x), pressing the letter d on my keyboard activates Downloads, the letter o activates OneDrive, and so forth.
 

Note that not including an ampersand symbol before Temporary in the Menu, Folders, Add, Temporary, !6 line means that I do have to use the mouse to open a folder which I’ve called Temporary (since pressing t will open my Terminology lists folder).

 

Finally, a word of caution, as also pointed out by Richard in his article: do be careful of any AHK scripts which you find on the internet as they have the potential to do anything assigned (even in an extreme case to wipe your hard drive!). It is vital that you understand the code before running any scripts.


AutoHotkey is a free, powerful tool for writing scripts that will run in any Windows application. It is used to automate certain repetitive tasks. AutoHotkey can make a huge difference to your computing life!

 

Check out my other blog posts about AutoHotkey:
 
Working more efficiently with AutoHotkey (part 2)
Working more efficiently with AutoHotkey (part 3)