UAT

Association of Personal Computer User Groups

Arizona Alliance of Computer Clubs

Validate


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?
http://phoenixpcug.org/works/autohotkey
Where do I get AutoHotKey?
Go to http://www.autohotkey.com, download the program, and install it
How much does AutoHotKey cost?
AutoHotKey is free, and 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 (google.com)

Just search for AutoHotKey Documentation to get started

Then search for more specific topics as you learn
Why not search from within the AutoHotKey site?
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
Is there a quick way to open the Explorer file manager?
Yes - press Win+E
Where is the Win key?
The Windows key is typically next to the Alt key
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
What program should I use to edit scripts?
Use 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:

autohotkey.com/docs/Scripts.htm#continuation
Can hotkeys perform different actions depending on the active or existing window?
Yes, hotkeys can be context-sensitive:

autohotkey.com/docs/Hotkeys.htm#Context
How can any two keys be used as hotkeys (without using Ctrl, Alt, Shift, and Win)?
See the custom combination examples:

autohotkey.com/docs/Hotkeys.htm#Features
How do I create windows, controls, menus, and forms?
Get your feet wet with simple hotkeys and hotstrings. Then see the GUI documentation:

autohotkey.com/docs/commands/Gui.htm
Can I write my own functions?
With ease. See the Function docs:

autohotkey.com/docs/Functions.htm
Can commands be used as functions?
Yes, see functions.ahk:

https://github.com/polyethene/...
Is there plenty of support for AutoHotKey?
Yes, in addition to the documentation, there are thousands of AutoHotKey articles and a community forum:

autohotkey.com/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
An Introduction to AutoHotKey
by Hank Pearson

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.