What AHK files are and why you'd save one

An AHK file is a plain-text script written in the AutoHotkey language. AutoHotkey is free software that lets you automate repetitive keyboard and mouse tasks on Windows — things like remapping keys, creating keyboard shortcuts, or running a series of actions with a single keystroke. When you save a file with the .ahk extension, Windows and AutoHotkey recognize it as a script that can be run.

You save as AHK when you've written automation code and want to turn it into a working script. The file extension tells your computer what program should open it and how to interpret the commands inside.

Key Takeaways

  • AHK files are plain-text scripts, so you can create and edit them in Notepad or any text editor without special software.
  • You must save the file with the .ahk extension at the end of the filename for AutoHotkey to recognize and run it.
  • After saving, you can run the script by double-clicking the AHK file or right-clicking and selecting "Run Script".
  • If AutoHotkey is not installed on your computer, download it from the official AutoHotkey website before trying to run AHK files.

Saving an AHK file in Notepad

The simplest way to create and save an AHK file is to use Notepad, which comes built into Windows. Open Notepad, type or paste your AutoHotkey script, then save it with the .ahk extension.

Here's the step-by-step process:

  1. Press the Windows key and type Notepad, then press Enter to open it.
  2. Type or paste your AutoHotkey script into the blank document.
  3. Click File in the menu bar, then click Save As.
  4. In the "Save as type" dropdown at the bottom of the window, select All Files (*.*) instead of "Text Documents (.txt)".
  5. In the filename field, type your script name followed by .ahk — for example, myscript.ahk.
  6. Choose where you want to save the file (your Desktop or Documents folder works fine), then click Save.

The "All Files" step is important. If you leave it set to "Text Documents", Notepad will add .txt to the end of your filename automatically, and the file won't run as an AutoHotkey script.

Saving from other text editors

If you use a different text editor like Visual Studio Code, Sublime Text, or even Notepad++, the process is similar but the menu names may differ slightly.

In most editors, you'll go to File > Save As, then type your filename with the .ahk extension. Some editors let you choose a language or file type from a dropdown — if yours does, you can search for "AutoHotkey" in that list, but it's not required. What matters is that the filename ends in .ahk.

If you're using Visual Studio Code, you can also install the AutoHotkey extension from the Extensions marketplace. This adds syntax highlighting (colors that make the code easier to read) and error checking, but the file still saves as plain .ahk the same way.

Making sure Windows recognizes the file type

After you save the file, check that it has the .ahk extension and not .txt. Right-click the file and select Properties. Look at the filename shown at the top of the Properties window — it should end in .ahk, not .ahk.txt or .txt.

If the filename shows something like myscript.ahk.txt, your text editor added an extra extension. Rename the file by right-clicking it, selecting Rename, and removing the .txt part so it reads only myscript.ahk.

You can also check the file type by looking at the "Type of file" line in the Properties window. It should say something like "AutoHotkey Script" or "AHK File" if Windows recognizes it correctly. If it says "Text Document", the extension is wrong.

Running your AHK file after saving

Once you've saved the file with the .ahk extension, you can run it by double-clicking it. If AutoHotkey is installed on your computer, the script will start immediately. You'll usually see a small icon appear in the system tray (the area near the clock in the bottom right corner) while the script is running.

If nothing happens when you double-click, AutoHotkey may not be installed. Download it from the official AutoHotkey website (autohotkey.com), run the installer, and then try double-clicking your AHK file again.

To stop a running script, right-click the AutoHotkey icon in the system tray and select Exit, or look for the script name in the list and click it to close just that script.

Editing an AHK file after you save it

You can edit an AHK file the same way you created it — right-click the file and select Edit (or "Edit with Notepad" if you want to be specific). Make your changes, save the file, and close the editor. The next time you run the script, it will use the updated code.

If the script is currently running, you'll need to stop it before your edits take effect. Right-click the AutoHotkey icon in the system tray, find your script in the list, and click it to close it. Then run the edited version.

Common mistakes when saving AHK files

The most common mistake is forgetting to change the file type to "All Files" in Notepad's Save As dialog. This causes Notepad to save your file as .txt instead of .ahk, and AutoHotkey won't recognize it. Always check the "Save as type" dropdown before clicking Save.

Another mistake is typing the filename as myscript.ahk.txt by hand. If you see .txt in the filename field, delete it — you only need .ahk at the end. The text editor will not add anything extra if you type the full filename yourself.

A third mistake is saving the file in a location you can't find later. Save to your Desktop or Documents folder so you know where it is. Once you're comfortable with AutoHotkey, you can organize scripts into a dedicated folder.

Frequently Asked Questions

Do I need special software to create an AHK file?

No. You can create an AHK file in any text editor, including the free Notepad that comes with Windows. You only need AutoHotkey installed on your computer to run the script after you save it.

What happens if I save an AHK file with the wrong extension?

If you save it as .txt or any other extension, Windows won't know it's an AutoHotkey script. Double-clicking it will open it in a text editor instead of running it. Rename the file to end in .ahk, and it will work.

Can I save an AHK file to a USB drive and run it on another computer?

Yes, as long as AutoHotkey is installed on the other computer. Copy the .ahk file to the USB drive, plug it into the other computer, and double-click it to run it. The script will work the same way.

Is it safe to download AHK files from the internet?

AHK files are plain text, so you can open one in Notepad and read what it does before running it. Only run scripts from sources you trust. If you don't recognize the code or don't know what it does, don't run it.

Can I convert an AHK file to an EXE file?

Yes. AutoHotkey includes a tool called Ahk2Exe that converts AHK scripts into standalone EXE files that can run on computers without AutoHotkey installed. You'll find this tool in your AutoHotkey installation folder after you install the software.