Version 4.1Copyright © Alan Cantor 2005 - 2014. All rights reserved.
Welcome to the Windows Macros FAQ. This resource is for people who want to operate Windows® more efficiently by taking advantage of macro software and macro techniques.
Running Windows® without macros is like cycling through the mountains on a fixed-gear bicycle. It can be done, but it is unnecessarily difficult. Think of macros as gears for your computer. Macros reduce physical and mental effort while multiplying speed and increasing efficiency.
This FAQ has four main sections. Fundamentals answers basic questions about macros. Smart Macros introduces the topic of macros with built-in intelligence. A smart macro acts on the basis of information received both from the user and from the user interface, and provides elegant, reliable, and seamless fixes to otherwise intractable accessibility and usability problems. The global hotkey section describes a standard Windows® technique for opening files, web pages, and folders, and for launching applications. The fourth section discusses two application-specific macro techniques: code replacement shortcuts and built-in macro languages.
This is a work-in-progress. Bookmark this page and check back often. Your feedback and questions are welcome.
A macro is a software shortcut for performing a series of steps or commands as a single task. Tasks may be simple, such as inserting a word; or complex, such as copying data from one program and pasting it in another. More sophisticated macros actively and passively collect information from the user and from the user interface, and make decisions on the basis of this new data.
Examples of tasks that can be performed using macros:
Macros save time, energy, and frustration. Macros automate repetitive, awkward, physically-demanding and mentally-taxing tasks. In addition, accessibility and usability problems can sometimes be fixed with macros.
Macro applications come in two "flavours:" those that act on programs from the inside; and those that act on programs from the outside.
Programming languages built into existing programs, such as Visual Basic for Applications (VBA) for Microsoft Office products, and PerfectScript for Corel products, do their work from the inside. Once created, the macros reside within and are integrated into the programs for which they are written. For example, VBA commands for Microsoft Word are stored in a binary file called Normal.dot. The commands and macros contained in this file load automatically each time Word is launched.
"Outsider" macro applications are third-party scripting utilities. The macros that these tools produce reside in the macro application itself (or in executables that the macro application generates). The macros are "outsiders" in the sense that the macro software is distinct from the programs it affects, and its macros act upon other programs — usually by sending keystrokes and/or controlling the mouse pointer.
Examples of full-featured Windows®-based macro scripting tools:
Other macro packages:
The macros produced by built-in programming languages tend to be more portable than those produced by third-party scripting tools. Whereas VBA macros should, in theory, work equally well on all computers, "outsider" macros may need tweaking — and sometimes rewriting — to work on another PC.
As a general rule, "insider" macros are more reliable than "outsider" macros, and "outsider" macros are more versatile than "insider" macros. A skilled developer knows how to make "insider" macros versatile, and "outsider" macros reliable.
Macro Express is powerful and easy to use. Keyboard Express, which is made by the same company, lacks many features included in Macro Express. ActiveWords is fairly easy to use, but lacks features found in Macro Express. AutoHotkey is very powerful but lacks a user interface to simplify macro creation; the learning curve is steep. Macro Scheduler is less versatile than either AutoHotkey and Macro Express. It is easier to learn than AutoHotkey, but harder to use than Macro Express.
VBA is a full-blown programming environment for controlling and interacting with an application's "objects." Learning to manipulate objects may be challenging for those without experience with other object-oriented programming languages. VBA is probably harder to learn than PerfectScript.
Full-featured screen readers have built-in macro scripting languages. The macro-writing tools in JAWS and Window-Eyes have been optimized for screen reader access, and work elegantly with speech.
Some software access problems are best resolved by scripting speech-friendly macros with third-party scripting tools. But because screen readers and macro applications both intercept input from the keyboard, conflicts can arise. The following compatibility information is based on reports from screen reader users:
Macro Express 3.x menus are difficult to access with JAWS, but it is possible. Set "Menu style" to "Flat" to improve screen reader access. (Options menu, Preferences...) Menus are easily accessed with Window-Eyes.
Overall, the Macro Express user interface is not particularly speech-friendly. Dialog boxes are fairly accessible, but some controls have non-standard behaviour, such as the list of hotkeys when choosing an activation method. It is possible to Tab to the list of hotkeys, but navigating backwards from the list causes Shift+Tab to be selected as the hotkey. Some wizards work better than others with speech, but most cannot be accessed without using the roving cursor.
Macro Express macros can be activated when JAWS is running, but not when Window-Eyes is running. I have seen people using Window-Eyes to script macros, and JAWS to test and run them.
Not yet tested with JAWS. ActiveWords does not appear to conflict with Window-Eyes.
Very easy to access because macros can be written in any text editor. The downside is that there is no user interface to simplify macro creation. No screen reader compatibility problems for activation have been reported.
No screen reader compatibility problems have been reported for JAWS or Window-Eyes.
VBA is fairly screen reader accessible, although some features are difficult or impossible to access with speech. Nevertheless, I have met developers with visual impairments who code in VBA via screen reader.
There are four main macro creation techniques:
Record command sequences by typing, pressing hotkeys, and manipulating the mouse. The technique works best for simple tasks; it is less reliable for complex ones. Some macro recorders capture mouse movements, and others do not. Captured mouse movements are notoriously unreliable when replayed. VBA's macro recorder ignores many (but not all) mouse movements, but it does reliably record the same actions when performed by keyboard.
A wizard guides the user through a series of questions, and automatically generates a script. Macros created in this way work best for simple tasks.
Type or insert commands directly into a macro editor. This technique is very powerful, but may require programming experience.
Select, insert, and edit commands via a user interface to build a script. This technique is adequate for crafting all but the most complex macros.
There are at least 13 different macro triggers. The six main ones are:
To activate a hotkey macro, the user presses a key or a key combination. There are two kinds of hotkey macros:
Code macros are triggered by typing text. The macro runs when a specific sequence of characters has been entered. There are two kinds of code macros:
When code macros execute, the code and the prefix/suffix are usually deleted. The macro may have untoward effects if pressing Backspace does something other than delete characters. In Internet Explorer, for example, pressing Backspace goes "Back" to the previous web page (unless an edit box has keyboard input focus.)
Timed macros activate at specific times, at set intervals, or after certain delays. They are used to run programs at set intervals, display timed reminders, and regulate the timing in multi-step macros. For example, when writing a macro to copy the URL of a web page and paste it in NotePad, it may be necessary to wait for NotePad to appear before issuing the "Paste" command. The macro might consist of five steps:
Macros execute very quickly. Without a "Wait" command, this macro may issue the paste command before Notepad gains focus.
Event macros execute when specified programs, windows, or controls gain or lose focus. Event macros are needed to regulate complex command sequences. The previous example will be more reliable if the "Paste" command is triggered by the appearance of NotePad (an event) rather than the passage of a fixed number of seconds:
Mouse macros are activated by clicking on specific areas of the screen; on user-defined menus or icons; or simply by clicking anywhere on the screen. For the latter type, it is usually necessary to hold down one or more modifier keys. Macros can also be actviated by clicking the middle mouse button.
Products like NaturallySpeaking and Microsoft Speech Recognition allow users to create custom commands. For example, a command that is invoked by saying "My Telephone Number" inserts a telephone number.
Scripting tools such as Macro Express and ActiveWords have steep learning curves, although adventurous novices who persevere will likely have success. AutoHotkey is closer to a programming language than a scripting tool, and may be harder for beginners to learn. On the other hand, its excellent help system contains many code samples that can be copied and pasted.
Macros for automating complex series of steps require intermediate- or advanced-level understanding of Windows® as well as good knowledge of the macro creation tool. A superior understanding of the keyboard interface is essential; macros that move the mouse pointer and click are unreliable. When writing smart macros, rudimentary programming experience is helpful, but not essential.
No special skills are needed to create very basic VBA macros because the macro recorder automatically generates the code. But to capture more than a few simple commands, you must work in the VBA editor and become familiar with the application's "objects" and "object model." If you lack an understanding of objects, you will gain it by the time your first macros are debugged!
I coined the term "smart" (or "intelligent") macro in 2005 to describe a computer shortcut that is activated either by the user or the user interface (UI), and performs tasks based on feedback that the macro receives from the user, the UI, or both. A smart macro mediates between the user and the computer, makes decisions, and acts on the basis of information it receives from two sources. In contrast, a "dumb" macro is always activated by the user, cannot be controlled once it has been activated (except, perhaps, to halt its execution), and neither detects nor acts upon information from the UI.
Smart macros have a modicum of built-in intelligence. This intelligence increases their flexibility, reliability, and accuracy. Well-designed smart macros dramatically improve software accessibility and usability in ways that cannot be achieved by other means — other than repairing the source code. A smart macro may be so seamless that users may not realize they are interacting with a macro. For smart macros that are triggered automatically or that workaround programming errors, there may be nothing new for users to learn or memorize. Smart macros simplify access to information because the macros themselves assume some of the physical and cognitive effort required to drive software.
Macros with built-in intelligence have four main uses:
A repair macro fixes an accessibility problem, usually within a specific window or program. For example, the "Options" dialog box contains a text field labelled "Address" (with underlined accelerator "A"), but pressing Alt+A does not move focus to the field. The repair macro, triggered by Alt+A, moves the focus to the text field by sending keystrokes, moving and clicking the mouse, or a combination of the two. This hotkey is available only when the titlebar says "Options," so Alt+A works normally in other windows.
A macro that fixes a usability problem forces a non-standard application to work the ways that users expect. If, for example, "Save" is F2 instead of Ctrl+S, a program-specific macro can be written to send F2 to the application when the user presses Ctrl+S. Because the macro is program-specific, the hotkey has no effect on other applications.
When automating a task to perform a series of actions, a dumb macro may play back faster than the computer can keep up. The only technique for a dumb macro to control information flow is to pause at critical moments. Macros with time delays tend to be unreliable because pause lengths vary and are unpredictable. This is especially true when a macro interacts with the Internet; network bottlenecks can easily throw off the timing of scripts that are regulated with time delays.
The smart macro's ability to process information from the UI allows for more reliable control. Rather than wait for preset time periods, a smart macro waits for specific events to occur, and tests that the events have occurred before continuing. Events that can be monitored include:
Testing for UI changes makes it possible to detect errors. For example, if a particular window does not appear within 10 seconds, the macro can stop, prompt the user for further instructions, or wait longer.
An automatic macro activates when a specific change occurs in the user interface. Many of the events listed above can serve as triggers. Automatic macros can also activate at set times or at regular intervals.
Choose any macro software product that supports these four features:
Windows® allows users to assign about 400 hotkeys for launching applications, opening files and web pages, and opening folders (such as "Recycle Bin," "My Computer," "Control Panel," and "c:\Windows\Desktop"). These hotkeys can be activated at any time, in any program, in any context. They are usually referred to as "desktop shortcuts," but because these shortcuts are always available, I refer to them as "global hotkeys."
When a global hotkey and an application-specific hotkey conflict, the global hotkey takes precedence.
Most global hotkeys consist of two or three modifier keys (Shift, Ctrl and Alt) plus one other key. Examples of keys that can be assigned include:
The following keys cannot form part of a global hotkey:
Follow this procedure to make global hotkeys:
The shortcuts do not have be on the desktop. They will work if they are placed in certain folders, but not in others. Shortcuts can be stored in "Start menu | Program Files | Shortcuts."
Global hotkeys become second-nature with practice. To help internalize the keystrokes:
Code replacement shortcuts insert information as you type. The code can be a word, a nonsense word, a number, a phrase, or a series of letters, numbers, and/or non-alpha-numeric characters. After typing the code, the shortcut is activated by pressing Spacebar, Enter, or a punctuation character.
Both Word and WordPerfect have code replacement features, AutoCorrect and QuickCorrect, respectively. Of the two, AutoCorrect is more versatile. QuickCorrect handles plain text and some formatted text; AutoCorrect handles plain text, most formatted text, images, tables, updatable fields, and more. Some (although not all) AutoCorrect features function in other Microsoft Office products. A code replacement shortcut added to Word usually will work in Excel and PowerPoint.
Code replacement is a boon to anyone for whom typing is difficult or awkward, including individuals with upper-body mobility impairments, and people with learning disabilities that affect hand-eye coordination and/or the ability to spell. People with low-vision also benefit because code replacement shortcuts reduce eye-strain. For example, the normal way to insert a symbol into a Microsoft Word document is visually intensive: navigate via a menu to a dialog box, choose the font and a font subset from drop-down lists, find the symbol, select it from an 8-by-24 cell grid, and click the "Insert" button. By creating, say, a two- or three-character code replacement shortcut for the symbol, eye-strain is eliminated.
There are many creative ways for improving computer access with code replacement shortcuts. The following descriptions and chart illustrate five different techniques:
This technique works well with people with learning disabilities, and other individuals who, for whatever reason, frequently mistype certain words.
Rather than repeatedly type long words and expressions, substitute short codes.
Simplify the insertion of the foreign characters and symbols you use regularly.
Eliminate the need to press the Shift-key when entering acronyms, words with unusual capitalization, and words and phrases containing alternate "upper" characters such as ! and @.
Enter chemical formulas like H2O and mathematical expressions such as ex on the fly. Use the same technique to insert images, tables, tables of contents, and fields.
|Correct misspelled words||untill||until|
|Abbreviate words and phrases||px||peroxide|
|sss||Sandy S. Smith|
|myletter||Thank you for your recent letter.
Sandy S. Smith
|Insert foreign characters and symbols||e/||é|
|Insert formatted text and images||h2so4||H2SO4|
|ourlogo||White, Black and Clear Attorneys
25 Grace St., Suite 200, York
Some applications have built-in programming interfaces. The programming language for Office, Visual Basic for Applications (VBA) is a subset of the Visual Basic (VB) programming platform. Whereas VB is designed to create stand-alone applications, VBA is designed to customize existing applications. Both VBA and VB are Microsoft products.
The built-in macro language for Corel applications is PerfectScript. Beginning in 1999, however, Corel has licensed Microsoft VBA for use with WordPerfect and several other Corel products. PerfectScript continues to be supported as a macro language for Corel products.
VBA can be used to build custom commands, repair accessibility problems, and develop usability enhancements in word processors, spreadsheets, database managers, e-mail applications, and presentation software. Not all programs offer VBA support. For example, VBA works with Outlook, but not Outlook Express. The application with the best VBA support is Microsoft Word.
There are two ways to create Word macros. Capture them using the macro recorder, or enter them directly in Visual Basic for Applications. The recorder cannot capture certain mouse movements (e.g., text selection via mouse), and recorded macros tend to replay slowly. They are also somewhat unreliable.
Macros coded directly in VBA, however, execute quickly and can be made extremely robust. A good way to learn VBA is the hybrid approach: record macros, and then study and edit the code. The VBA help system is excellent, and contains code fragments that can be copied and incorporated into new commands.
Feel free to submit your questions. Any comments about this FAQ are welcome.
A special thank you to Jane Berliss-Vincent, Dean Martineau, Neville from Australia, Frank Ibarra, and Paul Makulski for their important contributions to this FAQ. I also thank the hundreds of people who have attended my lectures, hands-on workshops, and web-casts on macros and macro techniques. Your questions and comments have helped to refine my understanding of the usefulness and power of macros.
The information contained in this FAQ is intended as a guide only. It is current to the best of the author's knowledge, having been compiled from sources believed to be reliable. No warranty, guarantee, or representations are made by the author as to the absolute correctness or sufficiency of any representation contained in this FAQ.
Microsoft, Windows, Word, Excel, Outlook, Outlook Express, Notepad, Visual Basic, Visual Basic for Applications, and Internet Explorer are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.
"Windows Macros FAQ" is an independent publication and is not affiliated with, nor has it been authorized, sponsored, or otherwise approved by Microsoft Corporation.