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.

AutoHotkey can use this 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. It has to be installed in order for the file to perform the tasks it was written to do.

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

Take extra care to only use executable files like these 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 files. Again, though, AutoHotkey 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't send that same 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 it to EXE, 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 yours is set up to just type out a sentence after you've entered a special combination of keyboard commands, then opening that specific 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 One

AHK files can be converted to EXE so that they can run without having to explicitly install AutoHotkey. You can read more about converting 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 file and choose the Compile Script option. You can also do this conversion through the Ahk2Exe program included in AutoHotkey's installation folder. You can search for it through the Start menu or look in this folder:

C:\Program Files\AutoHotkey\Compiler

AutoIt is a program that's similar to AutoHotkey but uses the AUT and AU3 file formats instead. There might not be an easy way to convert AHK to one of those formats, 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 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 will show or hide hidden files each time the Windows and H keys are pressed at the same time. This is much quicker than manually showing/hiding hidden files.

; 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 WIN+N is pressed.

#n::Run Notepad

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

#p::Run cmd

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

Still Can't Open It?

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's 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 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. 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 instead.

The point here is to research the file extension that it's using so that you can find the appropriate program that can open or convert the file.

Was this page helpful?