Skip to content

Instantly share code, notes, and snippets.



Last active May 7, 2019
What would you like to do?
Unofficial AutoHotkey FAQ

Unofficial AutoHotkey FAQ

Note: this page comes from the AutoHotkey Wiki which has been removed. It hopefully serves a purpose until the official faq can be edited in the new documentation setup. It is a good idea to check the official documentation to see if a new FAQ is available - April 2012.


This page is meant to list and categorize important forum threads, which answer the most frequently asked questions concerning AutoHotkey. It is a community effort to supplement the official FAQ page. If you have suggestions or would like to contribute, discuss it here: forum topic.

See also: Official AHK FAQ

Table of contents

  1. Purpose
  2. Getting Started
  3. Tools
  4. About AHK
  5. AutoHotkey_L (Current AutoHotkey version)
  6. Macros
  7. Files & Folders
  8. Text
  9. GUIs
  10. Graphics
  11. Window
  12. Testing & Debugging
  13. Security
  14. Communication
  15. Hardware
  16. Program Specific Problems
  17. Games
  18. More info

Getting Started

Questions on how best to learn AHK and common problems with your first script.


I just found AutoHotkey, looks great, but where do I start?

Search terms: tutorial, manual

Can't edit script?

Can't edit your script because it won't start (error) or unable to find your script?


Why does my script run fine in XP but not in Vista or Windows 7?


Questions about the tools that make scripting easier. These may be written in AHK or by third parties.


What is the best IDE to use for editing AutoHotkey Scripts?



Editors tailored for AutoHotkey or Made in AutoHotkey:

AutoHotkey syntax highlighting:

Visual Creators

Are there any WYSIWYG editors to create AHK GUIs by drag-and-drop?


Are there any auto-completion tools for AHK?


Can I create AHK [macros][] by recording my actions?


How can I generate professional looking documentation for my scripts?

Window Information Getters

How can I find the attributes of a window, such as its title, class, text, or mouse coordinates?


  • Launch Window Spy from a script's tray-icon menu (right click) or the Start Menu.
  • AHK Window Info 1.7 AutoHotkey script

About AHK

Questions concerning the origin of the language, its relationship to other languages, and theoretical discussion of programming as it relates to AHK.


How is AHK related to AutoIT?

Other Languages

What other languages are similar to AHK? Which language is the best or easiest to learn?

AHK in the Workplace

AHK could really help me out at work. How can I convince my boss to allow it?


What programming paradigm does AHK represent?


I'd like to make a donation to AHK's author. How can I do that?

Do note that there are now several people involved. Some are working on AutoHotkey (Lexikos), some on the website and forum (polyethene and moderators).


What license is AHK covered by? Am I allowed to sell my scripts for profit?


Can I run AHK from a USB drive?

In general:

  • AutoHotkey.exe (basic) looks for AutoHotkey.ini or AutoHotkey.ahk in the same directory and will automatically run that script.
  • AutoHotkey_L also looks for .ahk instead of AutoHotkey.ini or AutoHotkey.ahk. So if you rename AutoHotkey.exe to MyApp.exe it will run MyApp.ahk if it is placed in the same directory.

There are various scripts that might be helpful:

Compile a script:


Where can I find the official build, or older releases?

Update October 2012 AutoHotkey_L to replace AutoHotkey Basic

Read the Post by the author of AutoHotkey, Chris Mallet about the future of AutoHotkey(_L) October 2010

What forks and ports of AHK have been developed?

Are there AutoHotkey alternatives for Linux?

AutoHotkey_L (Current AutoHotkey version)

See note above October 2012 - AHK_L now simply AHK

Why does my AutoHotkey script no longer work with AHK_L


Questions concerning keyboard and mouse macros

Sending Text and Commands

What if the window I want to interact with isn't active or isn't visible?

Search terms (for games): multiboxing, WoW

Spam a Key

How do I spam a key?

Date & Time

How can I send the current Date and/or Time?

How can I send large blocks of texts as fast as possible?

  • Use the Clipboard see Sending or Storing texts for some suggestions


How to save and restore everything on the clipboard?

How to do math with data copied from Excel


Sending or Storing texts useful when sending long texts while preserving the clipboard



How do I detect the double click of a mouse button or the double press of a keyboard key?

Fn key

Can I use the Fn key on my Laptop as a hotkey?

Different Keyboard layouts

How can I use a hotkey that is not in my keyboard layout?


Can I use wildcards or regular expressions in Hotstrings?

Why don't my Hotstrings and/or Hotkeys work in my browswer / webforms or email program?



What's the difference between #IfWinActive and IfWinActive?

System Tray

How can I work with (system) tray icons?


Run at Specific Time

How do I limit when a script or function will execute?

Use Windows Task Scheduler!




Files & Folders

Questions about manipulating the files and folders on your hard drive.

Opened File Path

How to get the file path of the currently opened file(s)?

Monitor Folders and Files

How can I monitor a folder or a (log) file?

Search terms: tail, log

Selecting files

How can I process the selected files in explorer

How can I select files in explorer

Working with PDFs

In AutoHotkey:

Using external command line tools, using Run %comspec% /c.

Search AHK forum for examples...


Questions concerning string manipulation.


How can I read CSV data?

Tip: Do not use the StringSplit command as it may lead to unexpected results with anything but very basic CSV lists.

Text files

How can I remove or replace a line or .... in a text file?


How can I read or manipulate XML files


Questions concerning graphical user interfaces created by AHK.

Associated Variables

How can I save the contents of my GUI variables?

Error: The same variable cannot be used for more than one control.....

Hotkey Controls

When using Gui, Add, Hotkey, the Windows-key or mouse clicks are not detected


Can AutoHotkey Draw?

Apart from some rudimentary methods using Gui, drawing with AutoHotkey is limited. But there are other options:

How to make a Screenshot



How can I start an action when a window appears, becomes active etc?

Testing & Debugging

Questions about finding and fixing the errors in your code.

Basic Debugging

How can I debug simple scripts?

Advanced Debugging

How can I debug complex scripts?



My AntiVirus software flagged AHK as malware. Does it really contain a virus?

Note: Recent versions of the AutoHotkey installer no longer include UPX or MPress.

Search terms: virus, trojan, upx, false alarm, false positive


How can I protect my source code?

Search terms: compile, password, expir

Problems compiling your script?

I compiled my script, but I've lost the source-code. Can I get the AutoHotkey source back?

Recover deleted but still running AHK script


Browser Automation

Can AutoHotkey interact with browsers or webpages?

Search terms: com, httpquery, javascript, curl, wget, UrlDownloadToFile, UrlDownloadToVar


IE browser


Automation of Office Applications

Can AutoHotkey interact with Microsoft Office Applications?


How can I pass on variables or data from one script to another?

Search terms: ini, ipc, command line, onmessage


Can I use AutoHotkey to send e-mail?

Search terms: blat, cdo, mailto

Interact with command line

Can I use AutoHotkey to Interact with the command line?

Search terms: cli, dos, console, StdOut



Questions concerning the input and output devices AHK interacts with.

Multiple Keyboards or Mice

How can I distinguish a second keyboard or mouse?

Program Specific Problems




What are the most used commands in games?

  1. Send >> Sends simulated keystrokes and mouse clicks to the active window.
  2. Click / MouseClick >> Clicks a mouse button at the specified coordinates. It can also hold down a mouse button, turn the mouse wheel, or move the mouse.
  3. ImageSearch >> ImageSearch can be used to detect graphical objects on the screen that either lack text or whose text cannot be easily retrieved. For example, it can be used to discover the position of picture buttons, icons, web page links, or game objects. Once located, such objects can be clicked via Click.
  4. PixelSearch >> Searches a region of the screen for a pixel of the specified color.
  5. PixelGetColor >> Retrieves the color of the pixel at the specified x,y coordinates.
  6. Loop >> Perform a series of commands repeatedly: either the specified number of times or until Break is encountered.
  7. Sleep >> Waits the specified amount of time before continuing.
  8. SetTimer >> Causes a subroutine to be launched automatically and repeatedly at a specified time interval.


Why do Hotstrings, Send, and Click have no effect in certain games?

Not all games allow AHK to send keys and clicks or receive pixel colors.

But their are some alternatives, try all the solutions mentioned below. If all these fail, it may not be possible for AHK to work with your game. Sometimes games have a hack and cheat prevention measure, such as GameGuard and Hackshield. If they do, there is a high chance that AutoHotkey will not work with that game.

Use SendPlay via:

  1. the SendPlay command;
  2. using SendMode Play; and/or
  3. the hotstring option SP.

If you use Windows 7 and want to try SendPlay, read this SendPlay on Win7, Run as admin and disable UAC

To allow SendPlay even with UAC running and without running your script as admin, see Enable interaction with administrative programs by Lexikos

Increase SetKeyDelay. For example:

SetKeyDelay, 0, 50
SetKeyDelay, 0, 50, Play

Try ControlSend, which might work in cases where the other Send modes fail.


Send {KEY down}{KEY up}

with the various send methods


Send {KEY down}
Sleep 10 ; try various milliseconds
Send {KEY Up}

Read about DirectInput, XInput, Raw Input

There is also an Official FAQ on Games

More info

Suggestions welcome, post them here.

Other pages of interest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.