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
- Purpose
- Getting Started
- Tools
- About AHK
- AutoHotkey_L (Current AutoHotkey version)
- Macros
- Files & Folders
- Text
- GUIs
- Graphics
- Window
- Testing & Debugging
- Security
- Communication
- Hardware
- Program Specific Problems
- Games
- More info
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
- Official Quick start tutorial
- Tutorial for Newbies
- AHK Tutorials
- AHK Forum: How to Get Answers Effectively
- AHK Video Tutorials
Can't edit your script because it won't start (error) or unable to find your script?
- Messed up AHK and now I can't load scripts
- Lost my system tray icon... would like it back
- Debugging a Script (AutoHotkey documentation)
- Modifier/Hotkey combinations do not work
Why does my script run fine in XP but not in Vista or Windows 7?
- Autostart Autohotkey as Administrator
- Run as Administrator (Vista/Windows-7) A_IsAdmin Params
- Add "Run as Administrator" for AutoHotkey Scripts
- Enable interaction with administrative programs - Modifies AutoHotkey.exe Advanced
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?
General:
- The Extras folder included with AutoHotkey has some add-ons for editors AutoHotkey basic only
- How to change the default editor (Right click, edit this script)
Discussion:
Editors tailored for AutoHotkey or Made in AutoHotkey:
- SciTE4AutoHotkey v3 Stable
- Dev-PHP with AHK support
- AutoHotKey for Notepad2 and Notepad2 with AutoHotKey and Bookmarks
- QuickAHK v2.2
- AHK Studio
- Vic - A free text editor based on HiEdit control
- Listing of Editor related scripts in AutoHotkey Wiki
AutoHotkey syntax highlighting:
- AutoHotkey syntax highlighting for various editors search the forum for other editors
- AutoHotkey basic (download the ZIP) has some old(er) syntax highlighting files in the Extras\Syntax folder
- UltraEdit 9 - 18 Syntax Highlighting
- GreenPad
Are there any WYSIWYG editors to create AHK GUIs by drag-and-drop?
Are there any auto-completion tools for AHK?
- ISense, Intelisense for AutoHotKey classic
- How can context sensitive help for AutoHotkey commands be used in any editor?
- Auto-Syntax-Tidy v12
Can I create AHK [macros][] by recording my actions?
- Pulover's Macro Creator, Recorder & Script Writer
- Mouse Movement & Click Recorder
- AHK MouseRecorder
- Mouse and Key Recorder
- GG's Find Clickable Locs Window Aid
- Macro recorder For AHK Basic there is also the AutoHotkey ScriptWriter that comes with the AHK Basic installer
How can I generate professional looking documentation for my scripts?
- Natural Docs
- GenDocs v2 - part of SciTE4AutoHotkey or GenDocs v3 - standalone, custom pages, support for markdown
- Doc-O-Matic - beta AutoHotkey script
How can I find the attributes of a window, such as its title, class, text, or mouse coordinates?
DOES NOT WORK FOR WEB PAGES! USE COM
- Launch Window Spy from a script's tray-icon menu (right click) or the Start Menu.
- AHK Window Info 1.7 AutoHotkey script
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?
- What programming language does AutoHotKey use?
- Difference between autoit and ahk communities, activity, etc
What other languages are similar to AHK? Which language is the best or easiest to learn?
- More advanced programming language, AHK-like?
- Programming Languages Discussion
- What language is AHK most similar to ??
- Programing language
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:
- Script for people who like to run portable - 1 (doesn't use the registry)
- Script for people who like to run portable - 2 (does use the registry)
- Script manager by asred
- Script manager by pacifika
- Script manager by sumon
- OneIcon by nimda
Compile a script:
- Note about ahk2exe portability
- AutoHotkey_L (recommended)
- AutoHotkey Basic
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
- AutoHotkey, latest version AutoHotkey
- AutoHotkey Classic or Basic Archived
What forks and ports of AHK have been developed?
- AutoHotkey v2 Alpha Release by Lexikos
- AutoHotkey_L: Arrays, Debugger, #If expression by Lexikos (Unicode, ANSI, 64-bit) see note above October 2012, AHK_L now simply AHK
- AutoHotkey for Pocket PCs / WinCE / Smartphones by Micha
- IronAHK (alpha): cross platform .NET rewrite of AutoHotkey by polyethene
- AutoHotkey.dll, AutoHotkey_N Latest update AutoHotkey.dll, AutoHotkey_H by HotKeyIt (AHK_H includes AHK_L and AHK_N)
Are there AutoHotkey alternatives for Linux?
- Running AutoHotkey using Wine
- AutoKey - AutoKey is a desktop automation utility for Linux and X11
See note above October 2012 - AHK_L now simply AHK
Why does my AutoHotkey script no longer work with AHK_L
- Hotkey doesn't work anymore with Autohotkey_L
- Fundamental differences between AutoHotkey and AutoHotkey_L See WARNING and Script compatibility
Questions concerning keyboard and mouse macros
What if the window I want to interact with isn't active or isn't visible?
Search terms (for games): multiboxing, WoW
- ControlSend AHK Command
- Dual box script
How do I spam a key?
- The definitive autofire thread
- Auto fire Tutorial
- How to hold a key and spam it
- How can a repeating action be stopped without exiting the script?
How can I send the current Date and/or Time?
- Example using FormatTime AutoHotkey command
- Use the built-in variables
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?
- ClipboardAll example built-in variable
How to do math with data copied from Excel
Examples
Sending or Storing texts useful when sending long texts while preserving the clipboard
- Alternative 1: Send text via Clipboard: Clip()
- Alternative 2: Send / Store text via / in Clipboard: Virtual clipboards+, VirClip()
- WinClip - Direct clipboard manipulations (Class, requires AutoHotkey_L)
How do I detect the double click of a mouse button or the double press of a keyboard key?
Can I use the Fn key on my Laptop as a hotkey?
How can I use a hotkey that is not in my keyboard layout?
- Use a keys Scancode for a hotkey
- Script to find Scancode of a Key helps with setting up the above solution
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?
- AHK hotkeys and hotstrings blocked by FF, IE and Chrome? check your security software, AV, Firewall, other...
What's the difference between #IfWinActive and IfWinActive?
- #IfWinActive, Creates context-sensitive hotkeys and hotstrings. Such hotkeys perform a different action (or none at all) depending on the type of window that is active or exists. AHK Command
- IfWinActive, Checks if the specified window exists and is currently active (foremost) AHK Command
- #IfWinActive doesn't accept variables See #IfWinActive documentation
- Comment about using #If for context-sensitive hotkeys
How can I work with (system) tray icons?
- #NoTrayIcon, Disables the showing of a tray icon AHK command
- Open Tray Icon
- Extract Information and Manipulate TrayIcons
- Remove tray icon of terminated programs
- OneIcon - Tame your tray menu
How do I limit when a script or function will execute?
Use Windows Task Scheduler!
Automatically:
Manually:
Scripting:
Questions about manipulating the files and folders on your hard drive.
How to get the file path of the currently opened file(s)?
- Use WinGetTitle if the Program displays the path+file in the Window title AutoHotkey command
- Getting the command line information from a program using COM AutoHotkey_L
- GetCommandLine
- Process list, file names, command lines
How can I monitor a folder or a (log) file?
Search terms: tail, log
How can I process the selected files in explorer
- Use the Clipboard and a Loop in case of multiple files AHK Commands
- Can AutoHotKey retrieve file path of the selected file?
- Is there a way to get the current folder and list of selected files from an open explorer window when pressing a hotkey
- Access Explorer & IE Windows/Tabs; Open & Manipulate Windows com
- Get paths of selected items in an explorer window
How can I select files in explorer
- Select files/folders on the SysListView321 control of Explorer
- Select multiple files in the Explorer window programmatically?
- Open Windows Explorer with multiple objects selected
In AutoHotkey:
Using external command line tools, using Run %comspec% /c.
Search AHK forum for examples...
- Pdftk - The PDF Toolkit to merge, split, rotate, de/encrypt, metadata and much more ...
- Xpdf - Includes a PDF text extractor, PDF-to-PostScript converter, and various other utilities
- xdoc2txt - cmdline, COM or DLL - also for variety of other formats
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.
- Loop, parse, variable, CSV AutoHotkey command
- CSV Library
- TSV Table Manipulation Library Can work with CSV
- Example: Create, modify/edit/sort csv files using a Listview
How can I remove or replace a line or .... in a text file?
How can I read or manipulate XML files
- Any way to parse XML and fetch a value? - Using AHK 1.1+ built-in methods (ComObjCreate)
- XML wrapper - Build and parse XML
- XA Save / Load Arrays to/from XML Functions - Note XA_XMLEncode() needs to be 'fixed' (bad forum post)
Questions concerning graphical user interfaces created by AHK.
How can I save the contents of my GUI variables?
Error: The same variable cannot be used for more than one control.....
When using Gui, Add, Hotkey, the Windows-key or mouse clicks are not detected
Apart from some rudimentary methods using Gui, drawing with AutoHotkey is limited. But there are other options:
- Screen Capture with Transparent Windows and Mouse Cursor
- Capture Screenshot to JPG
- Capture Screenshot to PNG - GDI
- Transparent screen capture - ImageMagick
- Using Irfanview
- OCR.ahk - Library for recognizing text in images
- Use 3rd party tools - MSPVIEW, Abbyy, OneNote, Google Docs
- Screengrab --> OCR -- text, GUI for options/results - various versions throughout the thread
How can I start an action when a window appears, becomes active etc?
- WinWait and WinWaitActive - AHK commands
- WinTrigger: Watch de-activation/un-existance of windows...
- Hook on to Shell, HookWindow
Questions about finding and fixing the errors in your code.
How can I debug simple scripts?
- ListLines AutoHotkey command
- ListVars AutoHotkey command
- MsgBox (use it to show contents of a variable) or ToolTip AutoHotkey commands
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
- An open letter for Antiviral software companies
- Enough with the UPX packed virus false alarms
- Should UPX be removed from Autohotkey install?
- Virus warnings on Autohotkey
How can I protect my source code?
Search terms: compile, password, expir
- Convert a Script to an EXE (ahk2exe)
- SW Copy protection
- Time limit like a trial software for script, how to do it?
- Someone decompiled my passworded and protected script
- Password protect a script
- See the ahk2exe notes: As of v1.1.01, password protection and the /NoDecompile switch are not supported. Mpress can be used to compress the script executable. This also compresses the script source code. (Note: See AHK_L Decompiler below)
- Obfuscator for Autohotkey Scripts
Problems compiling your script?
- Microsoft Security Essentials breaks compilation
- Can't turn .ahk into .exe with win7
- Compile / Run AutoHotkey program
I compiled my script, but I've lost the source-code. Can I get the AutoHotkey source back?
- Script Decompiler AHK Classic
- Script Decompiler AHK_L (including UPX or Mpress packed exe)
Recover deleted but still running AHK script
Can AutoHotkey interact with browsers or webpages?
Search terms: com, httpquery, javascript, curl, wget, UrlDownloadToFile, UrlDownloadToVar
AutoHotkey
- UrlDownloadToFile AutoHotkey command
- httpQuery GET and POST requests
- libcurl example
IE browser
- Basic Webpage Controls with JavaScript / COM - Tutorial Internet Explorer
- Example of Navigating a Website
Firefox
- Combine iMacros and Firefox
- Retrieve AddressBar of Firefox, Internet Explorer or Opera through DDE Message
- Library: Remotely control Firefox - Class with MozRepl addon
- Accessible Library - not just for Firefox but can be used for FF
Can AutoHotkey interact with Microsoft Office Applications?
- MS Office Automation Functions (via COM)
- AHK_L MS Office Automation Samples (via COM)
- Basic Ahk_L COM Tutorial for Excel
How can I pass on variables or data from one script to another?
Search terms: ini, ipc, command line, onmessage
- Passing Command Line Parameters to a Script
- Use IniWrite and IniRead
- or FileAppend and FileRead
- Example: Send a string of any length from one script to another AHK Documentation, fourth example on page
- Interprocess communication (IPC) - module, ahk & dotNet
- Interprocess communication using Mailslots
- Reload with parameters
- SendData() - Sending data between scripts with SendMessage
- WorkerThread - easy and powerful Multithreading AutoHotkey_L, library
- talk() - class to communicate between scripts
Can I use AutoHotkey to send e-mail?
Search terms: blat, cdo, mailto
- Blat Dll usage
- CDO COM - Email delivery; AHK_L Version
- Instructing Outlook from the command line and using mailto
Can I use AutoHotkey to Interact with the command line?
Search terms: cli, dos, console, StdOut
- Run %comspec% /c
- FileAppend see stdout
- How can the output of a command line operation be retrieved?
- CMDret - AHK functions
- Retrieve standard output (StdOut) of a program
- StdoutToVar
- Function: Run - Retrieve and be notified about output from the console programs
- Using COM to interact with command-line programs
- Tip: retrieving command line output without a text file
- Compile/Run script as console application
- Copy text from DOS console using its system menu
Related:
Questions concerning the input and output devices AHK interacts with.
How can I distinguish a second keyboard or mouse?
- AHKHID - An AHK implementation of the HID functions Keyboards, Mice, Other
- Multiple keyboards workaround using HID Macros (external app)
- EitherMouse - auto switch mouse buttons on second mouse
- AutoHotkey script template for the 120 hotkey Enterpad (special keyboard)
- [ # no longer works as modifier in hotkeys with Firefox 17+] (http://www.autohotkey.com/board/topic/87602-autohotkey-stopped-working-for-firefox-only/#entry562905) just use LWin & KEY:: See custom combinations
What are the most used commands in games?
- Send >> Sends simulated keystrokes and mouse clicks to the active window.
- 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.
- 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.
- PixelSearch >> Searches a region of the screen for a pixel of the specified color.
- PixelGetColor >> Retrieves the color of the pixel at the specified x,y coordinates.
- Loop >> Perform a series of commands repeatedly: either the specified number of times or until Break is encountered.
- Sleep >> Waits the specified amount of time before continuing.
- 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:
- the SendPlay command;
- using SendMode Play; and/or
- 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.
Try
Send {KEY down}{KEY up}
with the various send methods
Try
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
Suggestions welcome, post them here.
Other pages of interest