AHK AutoHotkey — Saviour from the Mundane tasks of everyday

Swetha PN
4 min readMay 25, 2021

--

Photo by Andrew Neel on Unsplash

AHK — This article is to share my insights into the free AutoHotkey Windows utility for people who know little or nothing about it and how a little awareness about how to use it can save you enormous amounts of time.

Is AHK right for you?

Well, it depends. This tiny Windows utility helps in getting mundane tasks done with simple and quite useful scripts

AutoHotkey is a free, open-source scripting language for Windows that allows users to create small to complex scripts for all kinds of tasks such as form fillers, auto-clicking, macros, running batch jobs etc.

If you find yourself executing various routine tasks such as initiating servers with start-server.exe commands, health checks or manual workflows, you could greatly benefit by automating them.

  • To activate a CICD server or a reporting utility server or could be one of the SQL/noSQL databases — each from a different folder path using multiple Command Prompt windows.

Why AHK

For starters, its free. Scripts can be written in any notepad application and the complexity of scripts is next to writing an email with instructions to an intern.

AHK Slang

The extension of AHK scripts is .ahk

Sample scripts with extension

AHK scripts can be initiated with certain shortcut keys with a Symbol mapped to each of the Alt, shift and Ctrl keys.

AHK Shortcut Table — aka Hotstring

Install AHK software

Install AHK software :: https://autohotkey.com/download/

A simple script to see how to get it done

Task: To refresh the Page you are on every 5 minutes(300000 milliseconds)

AHK Refresh script

Script explained

· !1:: Alt+1

Maps the Shortcut key to the script

A mandatory step in the Line 1

The shortcut keys will be used to run the Refreshme.ahk script

Script Logic

Loop, 10{

Loop for 10 times

Sleep, 300000

Script to sleep or wait for 300 seconds/300000 milliseconds

Send, {F5}}

Send F5 keys thereby refreshing the current page view

return

Mandatory to place the return statement in the last line of the script

Some more Usecases

  • Start Grafana server from the root folder

AHK script to launch the command prompt CLI, wait till the window is active and send the instructions to navigate to the Grafana root folder and trigger the start executable

startgrafana.ahk
  • Start Influx DB

AHK script to launch the command prompt CLI, wait till the window is active and send the instructions to navigate to the InfluxDB root folder and trigger the conf file

Influxdb.ahk

How to Execute the Script

Step1: Have the script ready

Step 2: Initiate the script by double clicking it

Make sure the H icon is displayed in the system tray. It means that the script is initiated

System Tray — AHK Icon

Step 3: Run the Shortcut keys to execute the Script

The last step is to run the Shortcut keys to kick start the execution of script. The use of shortcut keys in order to trigger the batch job is referred to as a Hotstring — which is where the AutoHotKey name stemmed.

There is no limit to what one can achieve from the vast use of AHK.

References

Issues with installation with AHK are common. Refer the below documentation for sorting out most of them

https://www.autohotkey.com/docs/FAQ.htm#install

Share some of your AHK scripts to help the larger community.

--

--

Swetha PN
Swetha PN

No responses yet