If all you want is a quick overview of AutoHotkey, check out this Web page => "Introduction to AutoHotkey."
AutoHotkey is a scripting language which can make almost everything easier on Windows computers. It can be a simple one-line script in a text file which enters your e-mail address after only typing a couple of characters (i.e. "m@" when typed becomes "email@example.com"). There are some power apps which can make your computer life much easier. For example:
• Autocorrect over 5,000 commonly misspelled words in any Windows program or on the Web.
• Set a reminder for a later meeting.
• Use QuickLinks to replace the missing Windows 8 Start Menu (or just to make life easier in any version of Windows).
Or, check out the many of examples in the links at the bottom of this page.
by Jack Dunning
I noticed that the CNET download of AutoHotkey attempts to add another unwanted utility to your computer, so I recommend that you do a direct download from AutoHotkey. I did this without getting any annoying extra toolbars or utilities.
When installing AutoHotkey, there are three options, as shown in Figure 1. The Main Program is the interactive environment that allows you to write and run the scripts. The Script Compiler will convert the text script into an executable (EXE) file which will activate the new hotkey features directly on any Windows computer without installing the main program. "Enable drag and drop onto the script" is not active by default since it could cause the accidental launching of programs.
Figure 1. Installation of AutoHotkey has three options.
Once you've installed the latest version of AutoHotkey, you're ready to get started.
Writing an AutoHotkey Script
As with most script writing (programming) the basic file for writing code is a text file. Any text editor will do, although I recommend using Notepad++ which is one of my favorites referenced in Jack's Favorite Free Windows Programs. However, for the purposes here, Notepad which is the AutoHotkey default editor and included with Windows will do just fine.
To create your first script file, right-click on any open area of the Desktop. Select New => AutoHotkey Script from the menu (see Figure 2).
Figure 2. Create a new AutoHotkey script by right-clicking on the Windows Desktop.
A new file will be created with the name "New AutoHotkey Script.ahk" (see Figure 3). At this time you should change the name to something that will denote the purpose of the new script. In this case using "test.ahk" will work fine.
Figure 3. A new AutoHotkey file (AHK) is created on the Windows Desktop.
AutoHotkey scripts use the .ahk extension. If the .ahk does not appear at the end of the file name, the script will not automatically invoke the main program for activation. This is how the computer system recognizes AutoHotkey scripts.
To write your first script, right-click on your new file and select Edit Script from the menu (see Figure 4). The script will open in your default text editor (in most cases Windows Notepad).
Figure 4. Right-click on the file icon and select Edit Script from the menu to open the script in the default text editor.
The new script file will contain standard preliminary code, as shown in Figure 5. You can edit this information (Author), but for our purposes it's not necessary to make any changes. (Lines which start with a semicolon ";" are comments and do not affect the running of the script.) The lines at the bottom are AutoHotkey commands, but I have not yet investigated them. Based on the comments next to each command, it seems that they are good things to keep, so I left them as they are.
Figure 5. The new AutoHotkey script contains boiler plate text added by the main program when the new file was created.
The next step is to add the code which will create the hotkeys. In Figure 6, four different sets of code have been added to the script. Each section outlined in red activates a unique hotkey feature. They can be added to the script and tested individually or added all at once. (You can cut-and-paste the individual lines of code from the explanations below. It is important that the code (syntax) be exactly as it is shown or the hotkey will not operate properly.)
Figure 6. Four sets of code have been added to the script to perform the following functions: 1. Open a Google search in the default Web browser; 2. Launch Windows Notepad and return a message when it is closed; 3. Launch the Windows Calculator; 4. Convert "imho" to "in my humble opinion" anywhere it is typed.
Hotkey 1: Open a Google search with the default Web browser.
The number symbol (#) represents the Windows key (). The word "space" is the space bar. The hotkey is represented by the symbols which appear before the double colon (::). In this case #space means hold down the Windows key () and hit the space bar. The Google search screen will be opened in the default Web browser.
Hotkey 2: Open Windows Notepad; return a message when Notepad is closed.
Again, the number symbol (#) represents the Windows key (). The "n" is the letter n on the keyboard. In this case #n means hold down the Windows key () and hit the letter "n" on the keyboard.
This is an example of combining a number of commands into one script to be run sequentially. This is done by putting the hotkeys and the double colons on a separate first line (#n::). The following lines are executed in order when the hotkey combination is invoked. First Windows Notepad will open (RunWait), but the remainder of the script will wait until Notepad is closed. When Notepad is closed the message displayed is "The user has finished (Notepad has been closed)." The command "return" indicates the end of that routine and is required for every group of commands formatted in this manner.
Hotkey 3: Open the Windows Calculator.
The up-arrow symbol (^) represents the Control key (CTRL). The exclamation point (!) represents the Alt key (ALT). The "c" is the letter c on the keyboard. The hotkey is represented by the symbols which appear before the double colon (::). In this case ^!c means hold down the Control key, plus the Alt key and hit the letter "c" on the keyboard. The Windows Calculator will open.
Hotkey 4: Change "imho" to "in my humble opinion" whenever typed.
::imho::in my humble opinion
The code for this type of simple real-time substitution ("in my humble opinion" is added when "imho" is typed in any editing program or field) always starts with the double colon (::). The first group of letters are the hotkeys and the second group of letters following the second double colon (::) is the text which replaces the first group. It is activated when the first group is typed, followed by a terminating character such as a space, period (.), comma (,), quote marks, etc.
After you have added the new code to the AutoHotkey script, save the file.
Activating a AutoHotkey Script
When you have saved your new AutoHotkey script, you can activate it by right-clicking on the Desktop icon and selecting Run Script from the top of the menu (see Figure 7). The hotkey features will be loaded into memory and the functions will activate whenever you use the hotkey combinations.
Figure 7. Right-click on the AutoHotkey icon to activate it by selecting Run Script from the menu.
Note: Exercise some care when deciding which hotkey combinations you'll use in your script. In some cases they may override other common Windows hotkeys. In other situations, built-in program hotkeys may take priority over your assigned AutoHotkey hotkeys. For example, if you assign +E (#e) to an AutoHotkey script, the combination will no longer open Windows Explorer. On the other hand, if you try to use Control+H in an AutoHotkey script, it will not work in Google Chrome which will continue to open a History page.
After an AutoHotkey script is activated, a green icon containing the letter "H" will appear in the Notification area located at right-hand side of the Taskbar. If you hover over the icon with your cursor the file name of the script will appear (see Figure 8). Each time you activate a new script an additional icon will appear in the Notification area. You can run multiple scripts at the same time.
Figure 8. The icon in the Notification area will identify the running AutoHotkey script.
If you would like to deactivate (or reload a newly saved version of) an AutoHotkey script, right-click on the icon in the Notification area and make the appropriate selection (see Figure 9).
Figure 9. Right-click on the AutoHotkey icon in the Notification area to deactivate (Exit) the script.
This article should contain enough information to help you jump-start your AutoHotkey solutions—even if merely to change "imho" to "in my humble opinion." It should also offer enough insight into the scripting language for users to see how it could benefit them (and save key strokes) in their day-to-day computing. I would encourage everyone to give it a try. It's free and can make your computer work (whether word processing, writing e-mail, Facebook posting, or coding other programs) significantly easier.
For more information see the AutoHotkey Windows Tips and Tricks series in ComputorEdge.
1. A Look at the Power of AutoHotkey-An Introduction
2. Change the Case of Text from Upper to Lower and Back Again with AutoHotkey
3. Compile Your AutoHotkey Scripts into an Executable (EXE) File
4. Using StringReplace to Search and Replace Any Text in AutoHotkey
5. Writing AutoHotkey Scripts Is Not Just for Nerds
6. Enter the Current Date into Any Windows Program Automatically
7. Using the Graphic User Interface (GUI) Controls in AutoHotkey to Build Simple Gadgets
8. Automatically Resizing Windows with AutoHotkey
9. Write a User-define Function for Resizing Windows to Exact Dimensions on Your Desktop
10. Using AutoHotkey to Make a Window Always-on-Top and Solving Window Size Problems
11. Opening Hidden Windows Folders and Making Pop-up Help Windows in AutoHotkey.
12. A Tip for Organizing Desktop Clutter and More Power with AutoHotkey Replace