How to Learn AutoHotKey

Date: 2011-01-08
Author: Sean Gibson

Most online poker players have dabbled with AutoHotKey (AHK) scripts, which are handy shortcut tools that run in a Windows operating environment.  Many players appreciate the work that goes into creating an AHK script, but there’s a group of people out there who want to program their own.  Let’s take a look at a quick primer of how to get started.

An AHK script is actually just a plain text file containing commands to be executed by AHK.exe in Windows.  A script can contain hotkeys and hotstrings, but on its own, a script will perform its commands sequentially from top to bottom.

To create a script, download and install the AHK.exe program from the autohotkey.com website.  Then, right click on a spot on your desktop and in the menu that appears, select “New,” then “AHK Script.”  Another approach would be to open Notepad and start typing.  When you are done with your list of commands, save the file and make sure it ends in “.ahk” so it’ll work properly.

Let’s walk through an example.  For this first script, simply enter the following command:

#space::Run www.google.com

That simple line of code is actually your first ever AHK script!  The first character is the “#,” which stands for the Windows key.  So, “#space” actually equates to holding down the Windows key and then pressing the spacebar to activate the hotkey.  The “::” means that the subsequent command should be executed whenever this hotkey is pressed, which in our example takes you to Google’s homepage.

To wrap up your first programming experience with AHK, save the file and close it.  Then, making sure that AutoHotKey is loaded in Windows, double-click on your new AHK script.  Now that your script is loaded, hold down the Windows key on your keyboard and the spacebar at the same time.  Bam!  Your default browser loads up Google’s website for you.

You should note that multiple scripts could be running simultaneously, each with its own icon in your Windows taskbar.  To have a script launch automatically when you start your computer, just create a shortcut in the Start Menu’s “Startup” folder.

Let’s say you wanted to create a script to launch several programs at once like PokerStars and Holdem Manager.  The “Run” command is used to launch a program, document, URL, or shortcut.  Some common examples would be:

Run Notepad
Run www.pokersoftware.com

In theory you could type in:

Run C:\Program Files\PokerStars\PokerStars.exe
Run C:\Program Files (x86)\RVG Software\HoldemManager\HoldemManager.exe

When you run the script, it will open up PokerStars and Holdem Manager at the same time.  Now, you need to make sure the path part of the script is correct for your system, as it might be different from computer to computer.

Assigning a hotkey can also be helpful if you find yourself always referring to a program, like PokerStove, or just the calculator.  Here are two examples:

#n::Run Notepad
^!c::Run calc.exe

The first line of code makes it so that when you hit Windows key + N, Notepad will open.  The second line of code makes Control + Alt + C open up the calculator.  You can also have a hotkey open up multiple programs at once.  For example, if you wanted to run Notepad and PokerSoftware.com’s website at the same time, you could enter this:

#n::
Run http://www.pokersoftware.com
Run Notepad.exe
return

We made the last line of that code “return” in order to close up that hotkey’s list of shortcuts.  One very helpful shortcut you could make is for a signature when writing e-mails.  Here’s an example of making CTRL + Alt + S write a signature:

^!s::
Send Sincerely,{Enter}John Doe
return

Easy right? Obviously, this is the tip of the iceberg when it comes to AHK programming, but experimenting will let you create some very easy scripts that might help automate processes you do every day. Visit AutoHotKey.com for more details.  Also, check out our Beginner's Guide to AHK.


BECOME A MEMBER of PokerSoftware.com today. You can chat with us and ask questions to our poker software experts in the forums and get access to EXCLUSIVE members-only content. Sign up today!


More articles


 

WriteSubmit Your Comment Let us know what you think about this article!





 

Member Comments



 

No comments so far

Like PokerSoftware on Facebook and Get the Latest Software News Plus Weekly Prizes!

recomented-softwares Recommended Software

Tracking Analysis

SNG Tools

Training