| Barry MacDonnell's
Toolbox for WordPerfect
Macros, tips, and
templates for Corel® WordPerfect® for Windows®
| Page updated Aug 30, 2019
Main tips page | Browse more tips
| Make a key do "double duty" by assigning a macro to it, and
make the macro perform a task only if the key is struck multiple times (e.g., 2x,
3x, 4x, etc.)
Related pages -
Two-tap macros - Press a keyboard key twice in succession to perform a task, play another macro, etc. [The focus is on double-tap (2x) methods.]
Two-key macros - First press a shortcut key to play the macro, then press another alphanumeric key to perform some task or action.
Here are macros that can -
• Create a special graphic line with 4 taps of the equals (=) key.
• Automatically enter a hard return and simultaneous save the document.
• Delete multiple spaces at the cursor location and replace them with a tab.
• Automatically expand QuickCorrect abbreviations to create possessives.
These examples should help point the way for your own custom "double-duty" macros.
Note: To copy any of the macro code below into your WordPerfect program to create a working macro, see here.
A user on a Corel newsgroup asked:
"In [Microsoft] Word, there's a feature that lets you type, say, === and then hit enter, and it automatically becomes a double line across the page. Doing that with ### creates a triple line, with the line in the center thicker that the ones on the outside. Is there a similar feature in WordPerfect ...?"
Yes, if you use four sequential hyphens ("----") or equal signs ("====") at the beginning of a line. There is a setting in WP and it must be toggled on: Tools, Quick Correct, Format-as-you-go, Quicklines.
However .... If you want a different graphic line than the single- and double-line defaults that WP provides, this can be done with a macro assigned to the particular key (say, the "=" key). For example, the following macro will insert a full-width triple line (the center line being thicker) if you assign it to the "=" key, and then type four consecutive equal signs (on a blank line) in your document.
Please read the notes following the macro code.
// Beginning of macro code -
// If the character to the left is an equal sign (i.e., ASCII 61):
// Note: The next 3 Graphics... lines were
// recorded (Insert, Shape, Custom Line, etc.);
// delete them and re-record them to use a different line style -
GraphicsLineStyle (Style: "Triple 1")
GraphicsLineEnd (State: Save!)
// End of macro code
When the macro is assigned to the normal "=" key, pressing that key the first time plays the macro and makes the "Else" condition true, and the macro inserts a normal equal sign.
Pressing that key again plays the macro and makes the "If" condition true, and (if there are four equal signs to the left) the macro counts and deletes all equal signs up to the cursor, and inserts a graphical line in their place.
Assign this macro to the "=" key:
Click on Tools, Settings, Customize, Keyboards tab. Select the keyboard you want to modify. (Or click Copy to make a copy of it first: In the Copy Keyboard window, select the keyboard to copy, click Copy, and "Rename the object" with a new name, then click OK. Left-click the new keyboard's name and click Select to use it.)
Next, in the Customize Settings window, click Edit to edit the keyboard definition. Check the box at the bottom, "Allow assignment of character keys".
In the left window, scroll down to the "=" key and select it, then click Remove Assignment if there is any current assignment (say, some other macro or feature).
In the right-hand window, click the Macros tab and then Assign Macro to Key. Select the macro from the file directory, and click OK, then Close until you are back in your document.
You can have the "#" key (or any other unassigned key) perform this function by changing "61" to "35" in the two relevant lines above. Then assign the macro to the "#" key. (Note: I used an old ASCII chart to get these numbers. There are lots of places to get this chart; for example - http://www.ascii.cl/ and http://www.asciitable.com/)
You could assign a macro to a key that does something other than insert a graphical line.
For example, you could use the backslash key ("\") — just above the <Enter> key — to enter a hard return and save the file at the same time.
Here's a macro to do it (also included in MultiSav.zip). After adding it to your macros folder, assign it to the backslash key in the same way as explained in the paragraphs above.
Tip: To make the macro work with 3 consecutive backslashes, change
the If(vCount=2) to If(vCount=3).
// Beginning of macro code -
// If the character to the left is a backslash (i.e., ASCII 92) -
// Go backwards and count number of backslashesENDIF
// Return to original position
// End of macro code
Assign this macro to the "\" key. For the general method see Example 1.
Then pressing backslash twice cause the macro to delete the backslashes, then enter a hard return and save the file.
Click here for a macro that uses the ` key (next to the "1" key) to play a macro when the ` keys is pressed twice in succession.
This "double-strike" macro example deletes multiple spaces at the cursor location and then inserts a Tab.
Automatically expand QuickCorrect abbreviations to create possessives by "double-tapping" the single quote mark key (').
For example, if you have a QuickCorrect entry "pf" that expands to "plaintiff" when you press the spacebar, you can make it expand to "plaintiff's" with this technique.
When the macro below is assigned to the normal single quote key (see more, below), pressing the single quote key the first time plays the macro and makes the macro's "Else" condition true (i.e., there's no single quote on the left), and the macro simply inserts a single, straight (non-typographical) quote mark at the cursor location.
Pressing the single quote key once more plays the macro again and makes the "If" condition true (i.e., there now is a single quote on the left of the cursor). The macro then immediately types a space, then deletes the space. A space character enables QuickCorrect entries to expand.
You can then type an "s" to created the possessive of the previous (now expanded) word.
¤ If QuickCorrect is turned OFF (Tools, QuickCorrect, Replace words as you type), the macro will pop up a message to turn it ON.
¤ The typographical version of the single quote (the symbol (4,28), which has the numerical value of 1052) used below is the same one normally used in QuickCorrect's SmartQuotes tab. If you use a different SmartQuote for the single quote mark, you need to change the command below to match it. (Most users will not need to do this.)
// Macro code begins
vHR:=NToC(0F90Ah) // (<=hard return, used in Messagebox)
// Check if the item to the left is a single quote text character,
// or if it is a WP symbol (a typographical quote mark (symbol=4,28)):
If(CToN(?LeftChar)=39 or CToN(?LeftChar)=1052)
If(?QuickCorrect=False) // Display a message -
DeleteCharPrevious // Delete the quote mark
"QuickCorrect is currently OFF." +vHR+vHR+
"Turn it ON to expand QuickCorrect entries with" +vHR+
"Tools, QuickCorrect,'Expand words as you type.'")
Type(" ") // <= Space character
Type("'") // <= Straight, single quote between double quotes
// Macro code ends
Assign this macro to the single quote key
Click Tools, Settings, Customize, Keyboards tab. Select the keyboard you want to modify. (Or click Copy to make a copy of it first: In the Copy Keyboard window, select the keyboard to copy, click Copy, and “Rename the object” with a new name, then click OK. Left-click the new keyboard’s name and click Select to use it.)
Next, in the Customize Settings window, click Edit to edit the keyboard definition. Check the box "Allow assignment of character keys".
In the left window, scroll down to the single quote (it's just after the ampersand, "&") and select it, then click Remove Assignment if there already is an assignment. In the right-hand window, click the Macros tab and then Assign Macro to Key.
Select the macro from the file directory, and click OK, then Close until you are back in your document.
Tip: You might also want to assign the single quote keystroke to, for example, the '+Alt keys. In the event you need a single quote and the macro is not available (such as when editing a macro), this "backup" assignment might come in handy.