What Is an AHK File?

How to open, edit, and convert AHK files

A file with the .AHK file extension is an AutoHotkey Script file. It's a plain text file type that's used by AutoHotkey, a free scripting tool for automating tasks in Windows.

The AutoHotkey software can use the AHK file to automate things like clicking window prompts, typing out letters and numbers, and more. It's especially useful for long, drawn out, and repetitive actions that always follow the same steps.

AHK files in Windows 10

How to Open an AHK File

Even though AHK files are just text files, they're only understood and executed within the context of the free AutoHotkey program. This program must be installed in order to open an AHK file to perform the tasks that the file describes.

So long as the syntax is correct, the software understands what's written in the AHK file as a series of commands that AutoHotkey should follow.

Take extra care to only use executable files like AHK files that you've made yourself or that you've downloaded from a trusted source. The moment an AHK file exists on a computer that has AutoHotkey installed is the moment you put your computer at risk. The file might contain harmful scripts that could do lots of damage to both your personal files as well as to important system files.

The AutoHotkey download page contains both the full installer version of the software as well as a portable option for both 32-bit and 64-bit versions of Windows.

All that said, because AHK files are written in plain text, any text editor (like Notepad in Windows or one from our Best Free Text Editors list) can be used to build the steps and make changes to existing AHK files. Again, though, the AutoHotkey program must be installed to make the commands included in the text file actually do something.

This means if you make an AHK file on your computer and it works fine with AutoHotkey installed, you can not send that same AHK file to someone else who does not have the software installed and expect it to work for them too. That is, of course, unless you convert the AHK file to an EXE file, which you can learn more about in the section below.

It may not seem like you've opened an AHK file if the instructions inside the file don't do something obvious. For example, if your AHK file is set up to just type out a sentence after you've entered a special combination of keyboard commands, then opening that specific AHK file won't reveal any window or indication that it's running. However, you'll for sure know you've opened one if it's configured to open other programs, shut down your computer, etc. — something obvious.

However, all open scripts are shown in Task Manager as AutoHotkey, as well as in the notification area of the Windows taskbar. So if you're not sure whether an AHK file is currently running in the background, be sure to check those areas.

How to Convert an AHK File

AHK files can be converted to EXE so that they can run without having to explicitly install the AutoHotkey software. You can read more about converting AHK to EXE on the company's Convert a Script to an EXE (ahk2exe) page.

Basically, the quickest way to do that is to right-click the AHK file and choose the Compile Script option. You can also convert the AHK file through the Ahk2Exe program included in the installation folder of AutoHotkey (you can search for it through the Start menu or with a file search tool like Everything), which also lets you choose a custom icon file.

AutoIt is a program that's similar to AutoHotkey but uses the AUT and AU3 file formats instead of AHK. There might not be an easy way to convert an AHK file to AU3/AUT, so you may have to completely rewrite the script in AutoIt if this is what you're after.

AHK File Examples

Below are a few examples of an AHK file that you can use in minutes. Just copy one into a text editor, save it with the .AHK file extension, and then open it on a computer that's running AutoHotkey. They'll run in the background (you won't "see" them open) and work instantly when the corresponding keys are triggered.

This one is an AutoHotkey script that will show or hide hidden files each time the Windows key and H key are pressed at the same time. This is much quicker than manually showing/hiding hidden files in Windows.

; Use Windows Key +H to show or hide hidden files
RegRead, HiddenFiles_Status, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden
If HiddenFiles_Status = 2
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 1
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 2
WinGetClass, eh_Class,A
If (eh_Class = "#32770" OR A_OSVersion = "WIN_VISTA")
send, {F5}
Else PostMessage, 0x111, 28931,,, A

The following is a much simpler AutoHotkey script that's completely editable to your liking. It will open a program with a quick keyboard shortcut. In this example, we've set the script to open Notepad when Windows Key + N is pressed.

#n::Run Notepad

Here's a similar one that quickly opens Command Prompt from anywhere:

#p::Run cmd

See the online AutoHotkey Quick Reference for syntax questions and other AutoHotkey script examples.

Still Can't Open Your AHK File?

If your file doesn't run when AutoHotkey is installed, and especially if it doesn't show you text commands when viewed with a text editor, then there's a really good chance that you don't actually have an AutoHotkey Script file.

Some files use a suffix at the end that is spelled a lot like ".AHK" but that doesn't mean that you should treat the files as equals—they don't always open with the same programs or convert with the same conversion tools.

For example, maybe you really have an AHX file, which is a WinAHX Tracker Module file that has no relation to script files used with AutoHotkey. Or it could be an AHS file used with Photoshop.

Another similar sounding but totally different file extension is APK that's used for Android Package files. These are applications that run on the Android operating system and are as far from text files as possible, so if you have one of those, you won't be able to use the AutoHotkey openers from above to open it.

ASHX files are another example. Only one letter is added to that file extension, but the format has to do with ASP.NET web server applications and not AutoHotkey.

The point here is to research the file extension that you really do have so that you can find the appropriate program that can open it or convert it to a new format.