How to Write an AutoHotkey Script

Share

AutoHotkey

AutoHotkey is a fantastic but complicated piece of software. It was initially intended to rebind custom hotkeys to different actions but is now a full Windows automation suite.

AHK isn’t particularly hard to learn for new users, as the general concept is fairly simple, but it is a full, Turing-complete programming language. You will pick up the syntax much easier if you have a programming background or are familiar with the concepts.

Installing and Using AutoHotkey

AutoHotkey’s installation process is straightforward. Download the installer from the official website and run it. Choose “Express Installation.” After you’ve installed the software, you can right-click anywhere and select New > AutoHotkey Script to make a new script.

new autohotkey script

AHK scripts are text files with a .ahk extension. If you right-click them, you’ll get a few options:

  • “Run Script” will load your script with the AHK runtime.
  • “Compile Script” will bundle it with an AHK executable to make an EXE file you can run.
  • “Edit Script” will open your script in your default text editor. You can use Notepad to write AHK scripts, but we recommend using SciTE4AutoHotkey, an editor for AHK which supports syntax highlighting and debugging.

compile autohotkey script

While a script is running—whether it’s an EXE or not—you’ll find it running in the background in the Windows notification area, also known as the system tray. Look for the green icon with an “H” on it.

To exit, pause, reload, or edit a script, right-click the notification icon and select an appropriate option. Scripts will continue to run in the background until you exit them. They’ll also go away when you sign out of Windows or reboot your PC, of course.

autohotkey script running

How Does AutoHotkey Work?

Read the remaining 21 paragraphs

Source : How to Write an AutoHotkey Script