Autohotkey is an open-source scripting language for Windows that can be very useful to automate repetitive tasks. In this post, we will look at some example AutoHotkey scripts that might be useful particularly for developers. You might find one of the scripts helpful or you might get an idea about how AutoHotkey can be used in your developer setup.
KeyBoard Hotkeys
You can use AutoHotkey to map frequently used programs with keyboard keys. This example uses F5
to launch
Chrome and F6
to launch Visual Studio Code. If they are already open, both keys can still be used to
bring the program to front making switching between then easy which is particularly helpful when you have many apps open.
We can also extend this script to open a specific project folder in visual studio code or run specific commands after opening code.
Automatic Build
If you need to rebuild your application after every a file is changed in the project folder, then AutoHotkey can save you some time there. This following example keeps an eye on the project folder and all its subfolders and whenever a file is changed, it rebuilds the application. In this instance, we are using a simple Python HTTP server to demonstrate.
WatchFolder.ahk
is available to download from
AutoHotkey Forum.
Custom Search
Select any text and press ALT + S
or ALT + Left Click
to trigger the script. When triggered,
the script will copy the text and search it on google. You can choose any keyboard or mouse combination and
search the text on any search engine.
I use this script especially to search for errors and exceptions while I am writing code. I can also use custom search query. For example, let's say you are getting an error and the app says that it cannot concatenate string with int. What I like to do is, I would select that text and add the name of the language I am developing the app in, so the query would become, "cannot concatenate string with int python".
Files Filter
I download diagnostic log files on a regular basis at work and often they get lost in my downloads folder.
The following script helps me better organize the files. It loops through all the CSV
files in
downloads folder that contain the word diag
in the filename and moves them into the logs folder. Also,
it runs every time a new file is added in the downloads folder.
WatchFolder.ahk
is available to download from
AutoHotkey Forum.
What else can AutoHotkey do?
Virtually anything you can do with your keyboard or mouse. It can be used to simulate mouse clicks and key presses. You can also make HTTP requests, simple Graphical User Interface and file I/O with it. AutoHotKey Docs is a good place to start.
Running the Scripts
AutoHotkey files have an extension of .ahk
. To run a script, just double click it.
Please note that Autohotkey should be installed on your Windows computer and can be downloaded from
autohotkey.com. The examples in this post are written in version 1.1.30.03.
They are also available on
Github.
Thanks for Reading, I hope you found this article useful. 🙂