Home | Tips | Library | Other Authors | Other WP Sites | Writer's Links | Contact | Site Map

Barry MacDonnell's
Toolbox for WordPerfect

Macros, tips, and templates for Corel® WordPerfect® for Windows®
© Copyright 1996-2008 by Barry MacDonnell. All Rights Reserved.

Page updated June 20, 2008
WordPerfect Tips
Main tips page | Browse tips
"Two-key" macros can help organize macros under a common keystroke combination. Press one key to play the macro, then another to perform some action.

NOTE: The following material assumes you know how to edit macros and make changes. See the bottom of this page about copying macro code from a web page into WordPerfect.

Here are some of "2-key" macros for WP. They can be assigned to a keystroke combination. For help assigning macros to keys, click here.

When the first macro is played it will wait for any alphanumeric key (as well as Backspace, Delete, and Ctrl+Enter) and then take whatever action is set up for that key in the CaseOf commands.

The second macro uses the Char() command to display a small dialog and get the second keystroke. It will then take whatever action is set up for that key in the CaseOf commands.

The third macro, written by Roy Lewis and posted on WP Universe, uses push buttons on a menu as the second keystroke.

Another macro on this site, QWIKSET, uses a push-button menu, where the push buttons can also be "pushed" with a keyboard key -- making the macro a "2-key" macro. You press a key combination (e.g., <Alt+Z>) then press a second letter or number. With QwikSet, this causes the macro to dismiss the menu and execute the command.

SAMPLE MACRO #1

// Macro begins here -

OnCancel(End@)
OnError(End@)

PauseKey(Any!) // Wait for any key to be pressed

// Depending on which key is pressed, carry out the action(s) below -
Switch(?PauseKey)

// Note the following 6 examples:
// They are intended to demonstrate the general command format.
// However, if the macro is played "as is," they would simply
// cause the macro to terminate, so you must insert macro
// commands that perform some action after each CaseOf command

// Note that since there is a Default command at the end of
// all commands to terminate the macro, any keys that are
// not assigned to a CaseOf statement will cause the macro to end.

CaseOF ("0"):
CaseOF ("1"):
CaseOF ("2"):
CaseOF ("a"):
CaseOF ("b"):
CaseOF ("c"):
// ... etc.

// The following Default command executes if the second key is
// something other that a key specified in the CaseOF commands above

Default: vKey:=?Pausekey
MessageBox(; "No key assigned"; "The second key you just pressed, < " +vKey+ " >, has not been assigned to this macro." +NToC(0F90Ah)+ "Edit this macro and assign the key inside the macro's Switch command.")
Quit

Endswitch

Label(End@)
Quit

// Macro ends here

If, for example, the macro had this CaseOf statement-

CaseOF ("q"): If(?Substructure) SubstructureExit Endif CloseNoSave() Go(End@)

- and the macro was saved and assigned to the <Ctrl+k> keys, then pressing <Ctrl+kq> would cause the current file to be closed without saving it (i.e., it would "quit" the file). (Remember WordStar? This is one of WordStar's commands.)

SAMPLE MACRO #2

The next macro is slightly less complicated, and has the virtue of prompting the user with a dialog box. However, some people are annoyed with such a dialog, and may prefer the first dialog-less macro above.

Note that the accented letters used in the CaseOf commands shown in the example below were entered using the numeric keypad. For example, the è between the quote marks in the third Type() command was entered using <Alt+0232> on the numeric keypad. A list of the numerical values for these special characters can be found in the Windows character map (Start, Programs, Accessories, System Tools, Character Map).

// Macro begins here -

OnCancel(End@)
OnError(End@)

Char(nextc; "Enter a vowel: ")

vKey:=NToC(nextc)

Switch(NToC(nextc))

CaseOf "a":  Type("à")
CaseOf "A":  Type("À")
CaseOf "e":  Type("è")
CaseOf "E":  Type("È")
CaseOf "u":  Type("ù")
CaseOf "U":  Type("Ù")

Default:               MessageBox(; "No key assigned"; "The second key you just pressed, < " +vKey+ " >, has not been assigned in this macro." +NToC(0F90Ah)+ "Edit this macro and assign the key inside the macro's Switch command.")   
Quit

EndSwitch

Label(End@)
Quit

// Macro ends here

TIP - inserting accented characters:

Since the Sample Macro #2 above inserts accented letters, you might want to know that there are at least three alternative ways to create accented characters without using a macro or prompts.

According to Charles Rossiter, Corel C_Tech:

1. "Get an International Keyboard, or apply [in Control Panel, Keyboard] the US International keyboard definition to a standard US keyboard. This then works in all applications. [Windows XP users: For instructions, see the Microsoft Support Article # 306560, "How To Use the United States-International Keyboard Layout in Windows XP," at http://support.microsoft.com/default.aspx?scid=kb;en-us;306560]

2. In WPWin, create a series of keyboard keystrokes. For example, I use Alt+e for e-acute, Ctrl+Shift+E for E-grave, Alt+a for a-umlaut, Alt+Shift+O for O-umlaut, Alt+Shift+C for C-cedilla, etc. There is no conflict with other Alt-key shortcuts (eg Alt+a for T_a_ble): Alt+a gives a-umlaut; Alt,a gives T_a_ble (i.e., press and release the Alt key, then press a)."

NOTE: To use the second method (assign the accented letter to a key combination), follow the steps outlined here (see especially the section, "For keystrokes").

3. Use a utility such as the free program, AllChars, at http://allchars.zwolnet.com/. See the Introduction link on the home page for more information. (Not tested by this author, but recommended by other knowledgeable WordPerfect users.)

A more broadly useful program (not free, but a trial version is available) is As-U-Type at http://www.asutype.com/, which works well with WordPerfect's QuickCorrect, too.

SAMPLE MACRO #3

See Roy Lewis's macro on WP Universe at http://www.wpuniverse.com/vb/showthread.php?postid=40594#post40594. When a button is pushed from the macro's main dialog, this example macro types a word corresponding to the button's label. You will need to modify the macro's menu and other commands, but those familiar with writing WP macros should have little trouble doing this.

TO COPY A MACRO from a newsgroup message or web page:

Select all text from beginning to end, and copy it to the Windows clipboard with Ctrl+C or Edit, Copy. Next, open a blank document in WordPerfect and click on Tools, Macro, Macro Toolbar to display the Macro Toolbar. Position your cursor after any codes in Reveal Codes, and click on Edit, Paste Special, Unformatted Text to paste the macro code into the WP document.

Be sure to check for long lines that may have been wrapped into two or more lines with a hard return (HRt) between them; remove the hard return(s) to "glue" the lines back together.

Save it with the Save & Compile button on the Macro Toolbar. This will save it to your default macros folder.

Note that you may need to edit the Application() command at the top of the code (if one exists) to change the language code from "EN" (or "US") to the language version you are using.

Or, if you are using just one language version of WP, just delete the last semicolon along with the "EN," to get something like this: Application (WordPerfect; "WordPerfect"; Default)