Category Archives: AHK

AHK as a Developer Tool

AutoHotKey Scripting Software

AutoHotkey (AHK) is a powerful and versatile free, open source software and scripting language for Windows operating systems exclusively. It provides an environment where users can create custom scripts to automate repetitive and/or menial tasks, create custom GUI’s, manipulate windows, files and applications, and create custom hotkeys, macros, and key-rebinds. Users can quickly create and tailor scripts toward specific tasks they face to significantly improve their overall efficiency and minimize errors. In essence, AHK can be used to automate and otherwise enhance users’ ability to perform software development and other processes from start to finish.

Upon downloading AHK, the main Dashboard GUI has several useful features to help users get started and in general as they create scripts, including a compiler, link to Help Files, Settings, and a Window Spy tool to extract application window data. Using Window Spy, users can easily identify and access a window’s “ahk id” to hook into and directly input to that window using AHK methods, such as ControlClick, which sends mouse inputs to a given client at a specified x-y mouse coordinate. Conveniently, the Window Spy tool also provides functionality to easily identify the on-screen/client x-y coordinates of a given mouse position. There are similar functions for directly inputting strings (rather than clicks).

One of the most intriguing features of AHK which led me to pursue learning it on a deeper level is its capacity to directly interact with application client windows and any separate application GUI’s (including mouse and key inputs, minimizing/maximizing, setting window focus, and more) without focusing on them and interrupting other active processes. This is extremely beneficial for testing, data collection/recording and more – for example testing may be run in the background with the results recorded to an output file whilst the user is actively working on other tasks independently. Furthermore, AHK scripts can easily be set to repeat at a specified time period; the previously mentioned background testing/recording can be called upon to execute every X minutes with zero input from the user or interference on their tasks. Increased convenience and efficiency with less human error or interaction!

Some other functions in AHK which I have read or seen videos about and hope to start implementing soon include PixelSearch and ImageSearch. PixelSearch is a versatile tool of the form: 

PixelSearch, &OutputVarX, &OutputVarY, X1, Y1, X2, Y2, ColorID , Variation

Searching for a specified hexadecimal ColorID within the specified screen space and returning output variables containing the coordinates of the first found pixel of that color. The outputs can easily then be used in other functions, and this method synergizes well with other tools that may identify certain occurrences with a color highlight or other marker. The ImageSearch function works similarly, but takes an Image input (easily generated with the Window Spy tool) and searches for an occurrence of the input within the search coordinate range. An interesting component of both PixelSearch and ImageSearch is the Variation parameter visible above near the end of the PixelSearch skeleton. This variable allows variance in the color/image which is being searched for to increase the likelihood of finding the target even if minor screen/image shifts have occurred, which can be common depending on the application or instance.

There are countless other features and functions in AHK which I have not yet gotten a chance to learn about. If you or a friend/colleague have experience with AHK functions, feel free to reach out with questions/discussion/advice to my email at jelbirt@worcester.edu !

Information/Source Links:

Post discussing use of AHK for coding: https://python.plainenglish.io/coding-faster-with-autohotkey-453a2face9af
AHK Home site: https://www.autohotkey.com/
AHK Method Documentation –
ControlSend: https://www.autohotkey.com/docs/v2/lib/ControlSend.htm
ControlClick: https://www.autohotkey.com/docs/v2/lib/ControlClick.htm
PixelSearch: https://www.autohotkey.com/docs/v2/lib/PixelSearch.htm
ImageSearch: https://www.autohotkey.com/docs/v2/lib/ImageSearch.htm

From the blog CS@Worcester – Tech. Worth Talking About by jelbirt and used with permission of the author. All other rights reserved by the author.