ASCIi Group
AutoHotKey FAQ
Getting Started
by Hank Pearson
What is AutoHotKey?
AutoHotKey is a handy scripting language for developing useful tools in Windows.
Where is this FAQ (Frequently Asked Questions) on the web?
Where do I get AutoHotKey?
How much does AutoHotKey cost?
AutoHotKey is free.
You can even change the source code if you know how.
How do I learn AutoHotKey?
A
help file with examples is installed with AutoHotKey, but
Google's your friend
(
www.google.com).
Just search for
AutoHotKey Documentation to get started.
Then search for more specific topics as you learn.
(The Google search is often better than the search on individual sites.)
How do I restrict Google to search only within a site?
To search within a site, use the Google site: operator as in this example:
site:AutoHotKey.com custom combination keys
How do I create a script file?
In Explorer (Windows Explorer),
in the folder where you want to store your script, right-click an open area, choose New, and then AutoHotKey Script.
Name it as desired, keeping the .ahk extension, and press Enter.
Why not just create a text file with the extension .ahk?
You can. The script file is plain text.
But using the New, AutoHotKey Script option creates a template with a couple of standard commands.
Are the template commands required?
No, but they speed up your script.
How do I edit a script file?
Right-click the file name (in Explorer) and choose
Edit Script, using any text editor (such as
Notepad or
Notepad++).
Are there other standard commands to add to my template or script?
Yes, near the top, type
#SingleInstance force
This command replaces your script in memory each time you run it as you change and test.
How do I run a script?
Just double-click the file name, or select it and press Enter (like any other program).
Can I legally share my scripts?
Yes, there are no royalties or limitations involved.
Do my friends need to install AutoHotKey to use my scripts?
No, you can compile your scripts to create .exe (executable) files to share.
How do I create .exe script files?
Right click your .ahk script file and click Compile Script.
How do I write comments in an AutoHotKey script?
Single-line comments begin with semicolons (;).
Multi-line comments are enclosed in
/* and */.
How are long lines continued to the next line?
Very easily.
See Splitting a Long Line:
Can hotkeys perform different actions depending on the active or existing window?
Yes, hotkeys can be context-sensitive:
How can any two keys be used as hotkeys (without using Ctrl, Alt, Shift, and Win)?
See the custom combination
examples:
How do I create windows, controls, menus, and forms?
Get your feet wet with simple hotkeys and hotstrings. Then see the GUI documentation:
Can I write my own functions?
With ease. See the Function docs:
Can commands be used as functions?
Yes, see functions.ahk:
Is there plenty of support for AutoHotKey?
Yes, in addition to the documentation, there are thousands of AutoHotKey articles and a community forum:
What does a sample script look like?
/*
Practice.ahk
AutoHotKey script
*/
#NoEnv
SendMode Input
#SingleInstance force
MsgBox, , Practice,
(
Win+Slash
Edit notes.txt
pmm
Purple Mountain Majesty
Win+T
insert timestamp
Win+Down
Win+Up
roll mouse wheel
)
; Win+Slash edits notes.txt
#/::run %A_MyDocuments%\notes.txt
/*
pmm
typed in any text application
is replaced with
Purple Mountain Majesty
*/
::pmm::Purple Mountain Majesty
/*
Pressing Win+Down or Win+Up
rolls the mouse wheel
*/
#Down::Send {WheelDown}
#Up::Send {WheelUp}
/*
Win+T inserts a timestamp
formatted as you like, such as
2007-01-09 Tue 19:35
*/
#t::
FormatTime, TimeString,
, yyyyy-MM-dd ddd HH:mm
Send %TimeString%
return
; end Practice.ahk
Enjoy
AutoHotKey provides an enjoyable framework for creating tools to make your computing more interesting and productive.
Related article:
The Fun of Creating Tools
shows how easy it really is to create tools to make your computing more interesting and productive.
Includes useful examples and discusses the benefit of writing informal notes before writing code.