Quick Review of Auto Hot Key

It is sometimes useful to be able to automate things on a computer. To have a Batch file which will follow a set of instructions which you have prepared earlier.

Also Keyboard Macros can be useful, a Keyboard Macro is where a keystroke or a short sequence of key presses are replaced with a much longer sequence of keystrokes usually to save you having to type the longer sequence.

Auto Hot Key is a free/open source program which combines both these functions with a whole lot more. It is a program designed to control other programs, it can simulate keystrokes and mouse button presses for other programs.

Using Auto Hot Key you can change the way your computer behaves. You can write scripts which will be activated when a keypress or a sequence of key presses are made. Auto Hot Key becomes the glue which binds different programs together.

It usually hides in the background (terminate and stay resident) waiting for the appropriate sequence of keys before performing its assigned task but if you don’t set a keystroke or key sequence to wait for then the program will run once and then quit just like a normal batch file. Even many Auto Hot Key aficionados were not aware that you could do this.

As a batch processing language or scripting language it is very good. You can put forms and dialog boxes up on the screen, it has the full compliment of if statements and loops, it has a good set of functions and expressions for mathematics and string handling.

As a simple example of Auto Hot Key in use I use a program called ConnectedText quite a lot and I also use a program called VUE quite a lot. I had a problem that when I had a link to a VUE file in ConnectedText and clicked on the link it would open the file in a new VUE instance regardless of whether it was already open. This sometimes led to multiple instances of VUE open with the same file, this would be a problem if one of them were edited, or if two of them were edited in different ways.

The solution was to use Auto Hot Key to open the file instead, it would first check to see if that particular file was open in VUE, if it was then it would activate that window. Only if the file was not already open would it open the file in a new instance of VUE. So only one copy of each file would be open at any one time. It is a trivial program but quite useful.


IfWinExist VUE: %1%
    Run "C:\Program Files (x86)\VUE\VUE-launcher.exe" %2%
    WinWait VUE: %1%


There is another slightly more sophisticated AHK script I use which allows me to link into Compendium (normally Compendium does not support links into its contents). However this program will not be reproduced here. It is quite fragile and things need to be set up correctly for it to work.

The icing on the cake is that once you have a working script AHK files can be compiled into .EXE files.

Highly recommended.


3 thoughts on “Quick Review of Auto Hot Key

  1. Hi, would you mind explaining a bit more how to set up and use the above script? I added it to my active AHK file, but when I click on a VUE link in CT, it still opens multiple instances of the same VUE file.

    • The snippet of code was just given as a quick example.

      Set up a link in ConnectedText (or from another program) to run the compiled version of the AHK script.

      The script takes two parameters ( %1 and %2 ), the first is the name of the VUE file (as it appears in the window title bar) and the second is the name and full path of the VUE file.

      It ought to be possible to construct a program which would just take the full path and would split off the filename from that path in which case you could tell Windows to run the compiled file as the default for .vue files. I tried this back when I first discovered AHK but it didn’t work well. AHK has functions for doing just this, but they didn’t work consistently for me, maybe down to my inept programming. It failed if there were any spaces in the fullpath or the file name.

      I may revisit this at some point but then I would have the problem of finding and altering all the links to VUE files I have in my ConnectedText databases.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s