What Is an AHK File?
A file with the .AHK file extension is an AutoHotkey script. It’s a plain text file that’s used by a free scripting tool for automating tasks in Windows. AutoHotkey uses this file to automate things like clicking window prompts, typing, and lots more. It’s especially helpful for long, drawn out, and repetitive actions that always follow the exact same steps.
How to Open an AHK File
Even though AHK files are just made up of readable text, they’re only understood and executed within the context of the free AutoHotkey program. It has to be installed on the same computer the file is executed from in order for its tasks to be performed. 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. 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 one of these files on your computer, and it works fine with AutoHotkey installed, you can’t send that same file to someone else who doesn’t have the software installed and expect it to work for them, too. That is, unless you convert it to EXE, which you can learn more about in the section below. However, all open scripts are shown in Task Manager, as well as in the notification area of the Windows taskbar. So if you’re not sure whether one is actively running in the background, be sure to check those areas.
How to Convert an AHK File
AHK files can be converted to EXE so 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 Compile Script. 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: AutoIt is a similar program, but it 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 might have to completely rewrite the script in AutoIt if this is what you’re after.
AHK Script Examples
Below are a few examples of AutoHotkey scripts. 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. The following is a much simpler script that’s completely editable to your liking. It will open a program with a quick keyboard shortcut. In this example, we’ve set it to open Notepad when WIN+N is pressed. Here’s a similar one that launches Command Prompt from anywhere: This is another one we like that uses 7-Zip to automatically unzip an archive if you hold down Ctrl+Alt while you click once on the file:
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 good chance you don’t actually have one of these scripts. Some files use a suffix at the end that’s spelled a lot like “AHK,” but that doesn’t mean 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 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 use 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 your file is using so you can find the appropriate program that can open or convert it.