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%
{
    WinActivate
}
else
{
    Run "C:\Program Files (x86)\VUE\VUE-launcher.exe" %2%
    WinWait VUE: %1%
    WinActivate
}

 

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.

Advertisements