Classic Computer Magazine Archive COMPUTE! ISSUE 128 / APRIL 1991 / PAGE 67

Keyboard magic: turn your keyboard into a magic wand. (macro software) (includes related article on macro techniques)
by Barry Brenesal

The magic of macro software can turn your keyboard into a treasure chest of timesaving tools. With a single keypress, you can do the work of 10 - or 100 - keystrokes. Imagine, for example, pressing a single key and having the time and date pasted into your word processing document or having a single keystroke run a batch file. These are just two examples of what you can accomplish with macro software.

After typing almost any series of keystrokes enough times, most people will start looking for a shortcut. With the right macro software, you can simplify almost any task - no matter how complex - to a single keypress.

How Macros Work

Macros work by intercepting certain keypresses and substituting others. You tell the program the specific keys you want to use and exactly what they should accomplish.

For example, you could have your macro program send the string DIR/P, which gives a pageformatted directory listing, each time you press Ctrl-D at the DOS prompt. In macro parlance, Ctrl-D is called the hot key, and DIR/P is the macro.

In some macro software, the number of commands you can apply to a single key is only limited by memory and personal creativity. You could use a macro to move a budget file onto a ramdisk, invoke your favorite spreadsheet, load in the budget, or activate another macro file with useful key substitutions - all at the press of a single key combination.

Another keypress might print several files generated after a specific date, save them from hard drive to floppy, exit your application, and unload the macro program itself.

DOS also has many complex and difficult-to-remember series of parameters (can you remember how to format a 720K 3 1/2-inch disk in a 1,44MB drive, for example, or how to copy files with their archive bit set?). Applications have grown very powerful, but it's time-consuming to look up the parameters for all this in the documentation (assuming you don't first spend time looking for the documentation).

Macros present the perfect solution to these and other frequently used, complex commands. Create brief macros to match the common commands you'll need to issue, and file the documentation away.

Macro Marvels

Now that we've looked at some uses for macros, let's consider a few macro programs. The ones listed here are among the best, and they should be widely available (publisher's addresses are listed at the end of this article). Two of these, PC Tools Deluxe and Superkey, are commercial products. The others are shareware, available on many computerized bulletin boards. All offer good value, though each provides unique features that will be appreciated by users with specific needs.

If you subscribe to COMPUTE's PC Disk and want to give macros a try right now, see the section below on SuperMAC, the powerful macro program included on this issue's disk.

Anarkey. Macros are only a small part of Anarkey's features. It's a command line editor, especially helpful to the power user who wants more control over command entry in DOS. Anarkeys supports multiple commands per line and storage and retrieval of past command lines. Although this feature (often called command line history) is available in other operating systems and programs such as Digital Research's DR DOS 5.0 and PC Kwik's PCKKEY, only Anarkey includes a completion key that finishes command line entries upon request, based on the contents of the history buffer. The program can be placed in expanded memory, and it supports all versions of the LIM EMS, including 3.2 and 4.0.

Anarkey doesn't intercept keystrokes the way several other macro programs do. It was a little longer reinterpreting the onscreen ASCII character according to your recorded instructions. You might redefine d as dir. It still looks like d on the command line, but it now invokes a directory listing of all files.

Only letter-key combinations can be substituted as macros (no function or special keys). The program also expects the first word or uninterrupted series of characters to form a command and will try to execute it. Within these limitations, Anarkey is a powerful and reliable performer.

Newkey. This program combines some clever macro programming concepts with useful batch functions. Unlike most key-reconfiguration utilities, Newkey doesn't require DOS command line entry for key substitution. It comes with a pop-up application screen that can be invoked within most applications. From it, you can create, display, load, and save macros.

Batch operations use Pascal-style parameter commands for integration with macros. {WAITANY} stops macro playback until a key is pressed. {SLOWTYPE} resolves the problem of applications that cannot process fast macro playback, resulting in discarded keys. {CTRL + [} creates a variable-length entry filed - useful when you want to fill in the blank anywhere in a key substitution. A macro that starts My dear esteemed colleague will pause for your input and continue after you've pressed Enter with its predefined contents, it has come to my attention. . . .

Newkey also offers advanced features such as the ability to cut and paste between applications. When macro lists grow too long to keep in memory (yours, not the computer's), you can build colorful menus that display and configure them at the touch of a function key.

True, these are more advanced options that require a little effort. But Newkey's basic command structure is simple and intuitive. There's even an unexpected bonus: a guided tour online demo with very good abbreviated explanations of many features.

Superkey. None of these products are difficult to master, but Borland's macros are almost self-generating. After it has loaded, Alt-/brings up the pull-down menu screen. Commands are activated when you select them from menus via scrolling or press a hot key for first-letter entry on every level. F1 calls up good, brief context-sensitive help screens at any time.

Like Anarkey, Superkey includes a command stack option, which shows the last 255 characters entered at the command line. Like Newkey, it configures a display menu to review all active macros. Unlike neither Superkey provides DES (Data Encryption Standards accepted by the National Bureau of Standards) encryption. Of course, encryption, too, can be executed on a file from a macro.

A layout editor displays your keyboard layout on the top half of the screen. You can then move and redefine any keys, creating a separate file with the LAY suffix. Load in this file, and your reconfigured keyboard will be displayed in the bottom half of the screen. Painting it gives you a handy reference to changes created for that keyboard layout.

PC Tools Deluxe. The macro editor is only a small part of PC Tools Deluxe, but (as with the rest of Central Point Software's package) there's no skimping. It includes an attractive menu interface, options for timed pauses, and both fixed-and variable-length entry fields. Macros can be configured for universal operation, PC Tools activity only, or non-PC Tools activity.

While you probably won't buy PC Tools Deluxe specifically for its macro editor, the editor is certainly a useful feature to have available along with the excellent hard disk - management utilities. Read up on it sometime, while you're busy defragmenting your drive.

DKey. If Newkey, Superkey, and especially PC Tools Deluxe are the lions among macrowave. DKey is decidedly the mouse. But sometimes you don't want a lion for a task - especially when you have only a small memory hole in your 640K of conventional RAM to crawl through.

Even a few kilobytes of RAM can make the critical difference between success and a crashed program when you load some memory hogs. This is where DKey's 3.1K of RAM (including a default 1K macro buffer) is most welcome. There are no bells and whistles with this product - just simple, effective performance.

Ansikey. Huang's Ansikey is an outsider in this group. It uses the ANSI.SYS device driver that comes with DOS rather than RAM. The program reallocates up to 80 different key combinations, including F1-F12 and various key combinations with keywords [ALT], [CTL], and [SFT].

Since Ansikey functions outside memory, it won't work inside programs that use ROM Bios interrupts for keyboard input. Any application that redefines these will negate Ansikey's changes until you return to DOS. Depending on your needs, this can be either a negative or a positive feature.

Be warned: There are many excellent ANSI.SYS substitute drivers on the market, and they don't always work like Ansikey. You'll discover this immediately because the commands simply won't work. But if you can put Ansikey to work for you, you'll have a driver that will provide a small, effective macro utility that completely avoids RAM drain.


Getting on the macro bandwagon is easy with SuperMac, included on this issue's disk. Written by Rick Leinecker, COMPUTE's programming manager, SuperMac is a powerful program that goes head to head with the commercial and shareware products discussed above. If you subscribe to PC Disk, you'll find SuperMac on this issue's installment. If you don't subscribe and you'll like to order the disk, see "On Disk" elsewhere in the magazine.

In SuperMac, your macro definitions go in a text file, which you can create with a word processor in its ASCII mode or with a text editor. This text file needs to follow some simple syntax rules to SuperMac will be able to interpret it. When SuperMac runs, it loads your macro text file, converts it to a form that the computer understands, and then watches each keypress to see if one of your specified hot keys has been pressed.

There are two types of entries you can use in a macro. The first type is a special command. In the text file, these special commands must start with a < character and end with > character. The second type of entry is a literal character. These characters

Right after the BEGDEF directive, you specify the hot key that will activate your macro. Be careful when choosing these, since they may conflict with other hot keys and programs that you see. Notice that only the special commands are in brackets.

If you don't specify a filename, a file called SUPERMAC. MAC will be searched for in the current directory. You can specify a different filename by adding a command line argument with either a filename (that will be searched for in the current directory), a directory name (that will be searched for a file called SUPERMAC. MAC), or a full path and filename.

SuperMac does have a limit of 500 macros. You also have to consider that each macro allocates memory. This means that besides that 500-macro limit, you'll want to set a reasonable limit based on the amount of free RAM you want to give up.

There are two special hot keys built into SuperMac. One lets you uninstall the program by removing it from memory. The default hot key for this is Right Shift-Ctrl-F9. If it's not safe to uninstall (if another TSR is loaded after SuperMac or you're in an application, for instance), you'll hear a series of beeps, and the program won't remove itself. To remedy the situation, you can try unloading other TSRs that were loaded after SuperMac or quit your application and try again from the DOS prompt.

The other built-in hot key toggles the macro capability on and off. The default for this hot key is Left Shift-Ctrl-F10. You'll hear one of two frequencies of beeps here. The lower beep indicates that the program is inactive, and the higher one indicates that the program is active.

You can change these two hot keys by adding/h to the command line when you run SuperMac. When the selection screen comes up, all you have to do to pick a new hot key is press the configuration will be saved.

If you forget how to use SuperMac, you can type SUPERMAC/? from the DOS prompt and get a brief set of instructions.