Speed up any part of Windows by automating repetitive tasks using both the Scheduled Tasks tool (XP only) and a free automation tool (all versions of Windows). Part two of two
n part one of this tutorial we revealed how to use the Scheduled Tasks utility in Windows XP - different versions of Windows work in a different way, so consult the Help file for details.
When it comes to automating specific tasks within a program, you should use AutoHotKey. It works in a similar way to Microsoft Office - it can record your mouse clicks and keystrokes with the help of a built-in tool called AutoScriptWriter. Unlike Office, because AutoHotKey is designed to work across Windows and all Windows-based programs, it's a less exact science, so care is needed.
The key difference is that AutoHotKey records the mouse in a different way to Office - it doesn't record what you've clicked on, but merely records where the mouse is on your screen and that you've clicked it. When the macro is run again, it merely puts the mouse where you placed it originally and clicks. This is fine if the window or dialog box stays in the same spot, but if it moves for any reason your macro is rendered useless.
Thankfully you can control any program via the keyboard, and although there's a small period of adjustment you'll find that not only will your macros work every time, but you'll find shortcuts to speed up the way you use Windows too.
EXPERT TIP
If you don't assign a keyboard shortcut to your script, you must run it by clicking the script's icon in the Notification area of the taskbar after it's been launched. Far easier, then, to assign a keyboard shortcut - use the following line at the top of your script:
#k::
Replace 'k' with the key you wish to use. # indicates it's used in conjunction with the [Windows] key - replace this with ! for [Alt], ^ for [Control] and + for [Shift] (other shortcuts can be found in the Help file - look under Hotkeys).
Once saved, launch the script again and just press your choice of keys to launch it on-demand.
Plan your macro
Start by examining your program using the mouse to help you. Locate the options and dialog boxes you wish to incorporate in your macro and see if there are any keyboard shortcuts that could open the required box quickly - for example, to check your mail in Outlook Express, press [Ctrl] + [M].
Even if a shortcut doesn't exist, you can browse to the item quickly using keys: look at the menus at the top of the screen and you'll see one letter in each is underlined. If you press [Alt] + that letter (for example, V for View) you'll open the menu. You can then press the underlined letter of the option you want - P for Print Layout perhaps - or you can use the cursor keys to manually select the item in question. This way you can access any menu item without a mouse.
It's a similar process when navigating dialogue boxes. Look for an outline around a tab or dialog box - this is the currently selected box - and use [Tab] and [Shift] + [Tab] to move between boxes. If you need to select a different tab, select the first tab using [Tab] and then use the arrow keys to move between tabs.
When a box is selected you can type a figure into it; if it's a box, press [Space] to tick or untick it. Use the cursor keys for drop-down menus or to select a different radio box. To click OK when you're done, simply press [Enter].
Create your macro
Macros can be used to launch programs and then perform a specific action, but they can also be used to automate an action within a program - perfect if you want to be able to apply a group of different actions to any file with a single click or keypress.
Once you've rehearsed the moves you wish to perform, you're ready to record the basic actions of your macro. Download and install AutoHotKey from here, and use the step-by-step guide to help you get started with the AutoScriptWriter component.
EXPERT TIP
While it's possible to have more than one script running at the same time, it can be confusing working out which H icon refers to which script. You can alter the icon used to any your like by editing your script - search the Help file for icon to discover how it's done.
Step-by-step:
Create your first script in AutoHotKeys
1. SET UP
The simplest way to create a macro is by recording your keystrokes, so launch launch AutoScriptWriter from the Start > All Programs > AutoHotKey menu.
2. AUTO OR MANUAL
If your macro involves launching a program automatically, click Browse to select it. If it doesn't, launch the program manually and - if necessary - open a document.
3. DISABLE MOUSE
We don't recommend recording mouse movement, so press the Record Mouse button to de-select it. Now only keyboard presses will be recorded by AutoHotKey.
4. START RECORDING
Click the Red A-Record button and - if you didn't specify your program by clicking Browse in step two - highlight the program you wish to record by clicking it.
5. RECORD ACTIONS
Slowly - time is not an issue - perform the actions you wish to record. Remember, every key press is recorded, so consider rehearsing first if you keep making mistakes.
6. FINISH AND SAVE
When done, click the Stop button. Your recorded actions will appear in script form. If you're happy, click Save; if not, select all the text, delete it and return to step two.
After you've saved your script, what next? The box reveals how to fine-tune your script with the help of the program's comprehensive Help file. When you want to use the macro, double-click the file and an H icon will appear in the Notification area of the taskbar. You can run the macro simply by double-clicking this or using a keyboard shortcut you've created; alternatively convert it into a standalone program file that runs independently of AutoHotKey using the Ahk2Exe program, which is included with AutoHotKey.
Edit your macros
Once you've recorded your first macro, you'll see AutoHotKey's scripting language up close for the first time. You can edit this like any other text document in Notepad - just right-click the file and choose Edit Script, or do so within AutoScriptWriter.
One thing you may want to do is assign a hotkey to the script - this means that when it's running you can trigger it by pressing a key combination as opposed to double-clicking the script's icon in the Notification area of the taskbar. The Q&A reveals how.
If your macro is designed to work with multiple documents - in other words, you can run it on any open document in a program - you'll need to edit any references to the window name that refer to the program plus the document or file that was open when you recorded the macro. For example, if there's a reference to Paint Shop Pro - tut1.tif, delete the "- tut1.tif" part so it reads Paint Shop Pro. This will ensure the macro works with any file or document.
For more help on editing your macro, consult AutoHotKey's comprehensive help - access it by clicking Start > All Programs > AutoHotKey > AutoHotKey Help File.