Skip to Quick Links.
Google
WWW Cantor Access Inc.

Windows Macros FAQ
Version 3.0

Copyright © Alan Cantor 2004 - 2008 All rights reserved.

Content

Introduction

Fundamentals

Smart Macros

"Global Hotkeys"

Application-specific techniques

What are your questions?

Acknowledgements

Disclaimers

Trademark information



Introduction

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. I am now preparing a detailed guide on Macro Express, which is an excellent macro scripting tool. The guide will be for sale on this web site when it is complete.

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. Well-constructed smart macros provide 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 application-specific macro techniques.

This is a work-in-progress. Bookmark this page and check back often. Your feedback and questions are welcome.


Fundamentals

What is a macro?

A macro is a sequence of commands for performing a task. The tasks may be simple, such as inserting a word; or complex, such as copying data from one program and pasting it in another.

Examples of tasks that can be performed using macros:

Why write macros?

Macros save time, energy, and frustration. Macros can be written to automate repetitive, awkward, physically-demanding and mentally-taxing tasks. In addition, accessibility and usability problems can sometimes be fixed with macros.

What macro applications are available?

Macro Express and Keyboard Express (www.macros.com), ActiveWords (www.activewords.com), AutoHotkey (www.autohotkey.com), and Macro Scheduler (www.mjtnet.com) are examples of Windows®-based macro software.

Are macro development tools easy to use?

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.

Are macro applications screen-reader accessible?

Because screen readers and macro applications intercept input from the keyboard, the two applications can conflict. The following compatibility information is based on reports from screen reader users:

Macro Express

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.

ActiveWords

Not yet tested with JAWS. ActiveWords does not appear to conflict with Window-Eyes.

AutoHotkey

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 activition have been reported.

Macro Scheduler

No screen reader compatibility problems have been reported for JAWS or Window-Eyes.

How are macros created?

There are four main macro creation techniques:

Capture

Record commands by typing and manipulating the mouse. The technique works best for simple tasks; it is less reliable for complex tasks.

Wizards

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.

Direct editing

Type or insert commands directly into a macro editor. This technique is very powerful, but may require programming experience.

Semi-automatic scripting

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.

How are macros activated?

There are five main macro activation techniques:

Hotkey

To activate a hotkey macro, the user presses a key or a key combination. There are two kinds of hotkey macros:

  1. A single-key hotkey executes after pressing a single key or key combination. For example, a macro software package may allow you to launch an e-mail program by pressing Ctrl+E.
  2. A dead-key hotkey executes after pressing a sequence of two keys. Nothing appears on the screen when the first key is pressed; the macro activates only after the second key is pressed. For example, in some applications, pressing Ctrl+/ followed by O inserts Ø.

Code

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:

  1. Suffix macros are triggered by typing a code followed by Spacebar, Enter, and punctuation characters ("suffix keys"). For example, typing TEL followed by a suffix key inserts your telephone number; WP followed by a space launches a word processor; and SIG followed by a space, punctuation mark, or Enter inserts a signature file.
  2. Prefix macros are activated by typing a user-selected prefix followed by a code. For example, if J is the prefix, entering JTEL types a telephone number; JWP launches a word processor; and JSIG inserts a signature file.

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

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:

  1. Go to the Address line and select it. (In Internet Explorer, press Alt+D.)
  2. Copy to the clipboard.
  3. Switch to Notepad.
  4. Wait 2 seconds.
  5. Paste.

Macros execute very quickly. Without a "Wait" command, this macro may issue the paste command before Notepad gains focus.

Event

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:

  1. Go to the Address line and select it.
  2. Copy to the clipboard.
  3. Switch to Notepad.
  4. Wait until Notepad has focus.
  5. Paste.

Mouse

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.

What skills and knowledge do I need to write macros?

Some macros are easy to create. For example, global hotkeys (as described in the next section) and code replacement macros can be tackled by beginners.

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. Macros for automating a complex series of steps often require intermediate- or advanced-level understanding of Windows® as well as experience with the macro creation tool. A superior understanding of the keyboard interface is extremely helpful; macros that move the mouse pointer and click tend to be unreliable. When writing smart macros, a little programming experience is helpful, but not essential.


Smart Macros

What is a smart macro?

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 rather than a built-in feature. 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.

What are smart macros used for?

Macros with built-in intelligence have four main uses:

1. Repair accessibility problems

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.

2. Fix usability problems

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.

3. Regulate complex tasks

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.

4. Activate automatically

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.

How do I create smart macros?

Choose any macro software product that supports these four features:

  1. Scope, i.e., macros that work only in certain windows or programs.
  2. Conditional statements, e.g., IF - THEN - ELSE.
  3. Variables.
  4. Event triggers, e.g., macros that recognize when windows or controls gain or lose focus, a specific pixel changes colour, or the mouse pointer changes shape.

At least three third-party products for Windows® can be used to develop smart macros: AutoHotKey, Macro Express, and Macro Scheduler.


"Global hotkeys"

What is a global hotkey?

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.

What keys can be assigned?

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:

Without modifiers

One modifier

Two modifiers

Three modifiers

The following keys cannot form part of a global hotkey:

How do I create global hotkeys?

Follow this procedure to make global hotkeys:

  1. Locate the icon of an application, folder or file. Note: To make global hotkeys for Microsoft Office products, you will need to find each program's executable: winword.exe, excel.exe, outlook.exe, and so on.
  2. Create a shortcut.
  3. Move the shortcut icon to the desktop.
  4. Select the desktop icon.
  5. Invoke its "Properties" page.
  6. Go to the "Shortcut" tab.
  7. Go to the "Shortcut key" edit box.
  8. Press the desired key or key combination.
  9. Press Enter (or click the "OK" button).

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."

How can I remember my global hotkeys?

Global hotkeys become second-nature with practice. To help internalize the keystrokes:


Application-specific techniques

What is code replacement?

Code replacement is a technique for storing text and images as easy-to-remember codes. The code is replaced after it is typed. The trigger is usually 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. The technique is especially helpful to people with certain learning disabilities and those for whom typing is difficult.

Code replacement techniques

Use code replacement to correct spelling and capitalization errors, and to insert phrases, canned text, foreign characters, formatted text and images. The following chart illustrates five techniques: word, phrase, symbol, capitalization, and formatted.

Five code replacement macro techniques
Technique Code Replacement
Word px peroxide
pxs peroxides
Phrase sss Sandy S. Smith
myemail sssmith@pencilpusher.com
startletter Thank you for your recent letter.
Symbol e/ é
L= £
Capitalization alberta Alberta
csun CSUN
autocorrect AutoCorrect
Formatted h2so4 H2SO4
table3x2 Image of a 3-cell by 2-cell table.
ourlogo White, Black and Clear Attorneys
25 Grace St · Suite 200 · York

What about built-in macro languages?

Some applications have built-in programming interfaces. The programming language for Office, Visual Basic for Applications, can be used to build macros, repair accessibility problems, and develop usability enhancements.

Recording vs. authoring Word macros

There are two ways to create Word macros. Capture them using the macro recorder, or enter them directly in Visual Basic. 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 Visual Basic, however, execute quickly and can be made extremely robust. A good way to learn Visual Basic is to record macros and then study and edit the Visual Basic code. The Visual Basic help system is excellent, and contains code fragments that can be copied and incorporated into new commands.

  1. Choose a task to perform in Word. Before beginning, ensure that you know exactly how to perform the task. If a task involves selecting text, you must use keyboard commands.
  2. Start recording. Select "Tools | Macro | Record New Macro..." Name the macro. Assign a keyboard or toolbar shortcut.
  3. Record the macro. Perform the task without making mistakes.
  4. Stop recording. Click the "Stop" button on the "Stop Recording" toolbar, or select "Tools | Macro | Stop Recording."
  5. Test the macro.
  6. Study and refine the code. Press Alt+F11 to open the Visual Basic for Applications editor. Use the Help system to learn about the code and the structure of the language.

What are your questions?

Feel free to submit your questions. Any comments about this FAQ are welcome.


Acknowledgements

A special thank you to Dean Martineau, Neville from Australia, and Frank Ibarra 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.


Disclaimers

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.


Trademark information

Microsoft, Windows, Word, Excel, Outlook, Notepad, 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.


Quick Links

Services
All services
Seminars and workshops
Accessibility research
Job accommodation

Top of page
Resources
Windows with no mouse
Macros FAQ
Publications
Public presentations

Home
Company information
News
About Cantor Access Inc.
Our clients
Contact us

Site map


Copyright © Alan Cantor 1993 - 2008.
All rights reserved.
Updated: 1 January 2008
Legal | Privacy