Getting started with AutoHotkey
Remarks#
AutoHotkey is a free, open-source custom scripting language for Microsoft Windows, initially aimed at providing easy keyboard shortcuts or hotkeys, fast macro-creation and software automation that allows users of most levels of computer skill to automate repetitive tasks in any Windows application. User interfaces can easily be extended or modified by AutoHotkey (for example, overriding the default Windows control key commands with their Emacs equivalents). The Autohotkey installation includes its own extensive help file with an always updated web based version.
You can write mouse or keyboard macros, remap keys, create hotkeys, expand abbreviations, change clipboard contents, and make executables to run hotkey scripts on computers without AutoHotkey installed.
Versions#
AutoHotkey 1.0.* - also retroactively known as AutoHotkey Basic, Classic, Vanilla, etc.
(Development was discontinued in 2011; Latest stable: 2009)
Version | Release Date |
---|---|
v1.0.48.05 | 2009-09-26 |
v1.0.97.02 | 2011-04-14 |
AutoHotkey 1.1.* - previously known as AutoHotkey_L.
(Stable and receives updates regularly)
Version | Release Date |
---|---|
v1.1.24.00 | 2016-05-22 |
v1.1.24.01 | 2016-08-02 |
AutoHotkey 2.0-a*
(Still in alpha stage)
Version | Release Date |
---|---|
v2.0-a069 | 2015-10-24 |
v2.0-a070 | 2015-11-09 |
v2.0-a071 | 2015-12-25 |
v2.0-a072 | 2015-12-25 |
v2.0-a073 | 2016-02-05 |
v2.0-a074 | 2016-03-11 |
v2.0-a075 | 2016-06-03 |
Installation or Setup
From Autohotkey Site Documentation
- Go to the AutoHotkey Homepage.
- Click Download, once downloaded run the executable.
- During installation of AutoHotkey, you will be asked to choose from UNICODE or ANSI. In short, you would probably want to choose UNICODE. It has support for non-English letters and numbers (characters).
- Keep going until you see an Install button.
- Once done, great!
Use as portable software
- Go to the AutoHotkey’s download page.
- Find the Portable section, choose from UNICODE 32, 64 or ANSI and downloaded.
- When choosing the destination folder, pick any correct storedevice external or not.
- Now you can opt to associate .ahk files with Autohotkey.exe
- Create a plain text file and give it the .ahk extension
- Then Right-click on the .ahk file in explorer and click Properties.
- In the file Properties, click the Change button next to the “Opens with” option.
- After clicking Change, you’ll be given a list of programs to open
- If the program you want to select is not listed, click the
- Now .ahk files will run as if autohotkey was installed, great!
If you have chocolatey installed, run the following command as an admin user
choco install autohotkey
Alternatively, it can be built from the source code. See here for details:
https://github.com/Lexikos/AutoHotkey_L/
Hello World
Show a “Hello World!” in message box.
MsgBox, Hello World!
Show a “Hello World!” in tooltip.
#Persistent
Tooltip, Hello World!
Show a “Hello World!” message in the traybar edit.
#Persistent
TrayTip,, Hello World!
Prints “Hello, World” to Standard Output (stdout).
FileAppend, % "Hello, World", *
Show “Hello World” in a GUI
Gui, Add, Text,, Hello World!
Gui, Show, w200 h200
return
GuiClose:
ExitApp
Achieve an effect similar to SplashTextOn
Gui, +AlwaysOnTop +Disabled -SysMenu +Owner ; +Owner avoids a taskbar button.
Gui, Add, Text,, Some text to display.
Gui, Show, NoActivate, Title of Window ; NoActivate avoids deactivating the currently active window.
How to create a Script
Once you have AutoHotkey installed, you will probably want it to do stuff. AutoHotkey is not magic, we all wish it was, but it is not. So we will need to tell it what to do. This process is called “Scripting”.
- Right-Click on your desktop.
- Find “New” in the menu.
- Click “AutoHotkey Script” inside the “New” menu.
- Give the script a new name. Note: It must end with a .ahk extension. Ex. MyScript.ahk
- Find the newly created file on your desktop and Right-Click it.
- Click “Edit Script”.
- A window should have popped up, probably Notepad. If so, SUCCESS!
So now that you have created a script, we need to add stuff into the file. For a list of all built-in commands, function and variables, see section 5. Here is a very basic script containing a Hotkey which types text using the Send command when the hotkey is pressed.
^j::
Send, My First Script
Return
We will get more in-depth later on. Until then, here’s an explanation of the above code.
- The first line.
^j::
is the Hotkey.^
meansCTRL
,j
is the letter j. Anything to the left of::
are the keys you need to press. - The second line.
Send, My First Script
is how youSEND
keystrokes.SEND
is the command, anything after the comma (,) will be typed. - The third line.
Return
. Return will become your best friend. It literally STOPS code from going any further, to the lines below. This will prevent many issues when you start having a lot of stuff in your scripts.
- Save the File.
- Double-Click the file/icon in the desktop to run it. Open notepad or (anything you can type in) and press Ctrl and J.
- Hip Hip Hooray! Your first script is done. Go get some reward snacks then return to reading the rest of this tutorial.