Home | Tips | Library | Other Authors | Other WP Sites | Writer's Links | Contact | Site Map | Donate |
Barry MacDonnell's Toolbox for WordPerfect |
||
Macros, tips, and
templates for Corel® WordPerfect® for Windows® |
Page updated Dec 8, 2022 |
|
WordPerfect
Tips Main tips page | Browse more tips |
||||
"Two-key" macros
can help organize related macros or tasks under a common keystroke
combination. You then can use the same shortcut key combination (e.g., Alt+z) to play the macro, and then separately press any one of several alphanumeric keys (e.g., "1") or menu choices to perform some action. (Here: "<Alt+z>,1". You could then use "<Alt+z>,2" etc. for another task.) Related pages - Two-tap macros - Press a keyboard key twice in succession to perform a task, play another macro, etc. Double duty macros - Make a key do "double duty" by assigning a macro to it, and make the macro play only if that key is struck multiple times (e.g., 3x, 4x, etc.) |
Here are several "2-key" macros for
WordPerfect. They can be assigned to any available shortcut key to play them. Then you will only need to [1] use a
single shortcut key to start the macro, and then [2] immediately use a previously designated alphanumeric key or menu choice to do other things — such as insert accented letters,
perform a task, etc. Advantages You can just assign the two-key macro to a
single shortcut key and reserve other shortcut keys for other things. Using the same shortcut key as a "gateway" to multiple (usually related) functions makes it easy to remember, too. Tips - You don't have to use two keys with some of the examples below. You could
also use a toolbar button to start the macro with a mouse click, and
then press a designated alphanumeric key — or in the case of a push-button menu, either a
second key or a mouse click — to do some task such as play another macro,
type some text, load a document, etc. See examples below. Examples • When the first macro
below is
played it will pause and wait for any alphanumeric or punctuation key (as well as
Backspace, Delete, Enter, and Ctrl+Enter) and then take whatever action is set
up for that key in the CaseOf() commands. (See instructions in the
macro's code.) Note this example does not use a menu of choices when
the macro is played, so you will need to remember what each key does.
• The second macro below uses the Char() command to display a small dialog menu to get the second keystroke. It will then take whatever action is set up for that second key in the CaseOf commands. (The example simply inserts an accented letter into the document, such as "à".) Note this example's dialog also acts as a reminder about what to do and what will happen when you press the next key. Macros that use multiple push buttons for user choices: • The third macro below uses push buttons on a menu to apply UPPER case, Initial Caps, or lower case to the current word or selection of text. • The fourth macro below uses push buttons on a menu to insert various closings for letters ("Sincerely yours," etc.) with a pick-list choice of sender name. • The fifth macro below, written by Roy Lewis and posted on WP Universe and somewhat more advanced due to the use of a CallBack routine, uses mnemonically labeled push buttons on a menu as the second keystroke. (The example then executes various other code routines that you can either record and paste into the macro code, or write and insert into the macro code, in place of the existing Type() commands.) • Another macro on this site, QWIKSET ("Quickly set relative font sizes and other attributes with a keystroke") 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, as with other pushbutton examples here, the second key press dismisses the menu and executes the command. [Tip: Push button menus are good for many "two key" macros since either pressing the keyboard key corresponding to the button's underlined letter or number (e.g., x) or clicking directly on the push button with your mouse immediately dismisses the menu and carries out the assigned task. See Footnote 2 for an example of a push button menu that was set up to use all 26 letter keys and 10 number keys. [While most users would not find that example practical — how will you remember what each of the 36 buttons does? — the overall structure and the syntax of its commands might be useful in many other macros.] ■ Sample macro 1 To copy this macro code into your WordPerfect to produce a functioning macro, see here.
Default:
vKey:=?Pausekey
If, for example, the macro had this CaseOf statement - CaseOf ("q"):
If(?Substructure) SubstructureExit Endif - and the macro was saved and assigned
to the <Ctrl+k> keys, then pressing <Ctrl+k><q> would
cause the current document to be closed without saving it (i.e., it would
"quit"). [Old timers might remember WordStar: This was one of WordStar's
commands to quit the document.] ■ Sample macro 2 The next macro is slightly less complicated, and has the virtue of prompting the user with a simple dialog box. [However, some people are annoyed with such a dialog, and may prefer the dialog-less macro in Sample #1 above.]
• The
accented letters
used in the CaseOf commands shown in the example below
were entered using the numeric keypad (see next paragraph). They can also be selected and
copied from the Windows Character Map on your system, then pasted into
the relevant Type() command between the double quote marks.
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. (You can use
Start, Programs,
Accessories, System Tools, Character Map -or- in more recent versions
of Windows, use the Windows search field and search for "Character
Map"). For some items it can be easier to use the select-copy-paste method directly from the Character Map. Tips • To copy this macro code into your WordPerfect to produce a functioning macro, see here. • You can make copies of the macro's code
below to use as separate macros. For example, instead of the grave accent
(`) marks, use acute accent (´) or umlaut (two dot) marks. Save and compile the macros and then assign
each macro to separate shortcut keys (instructions here) — using keys that are available and (preferably) easy for you to
remember. For example, you could assign the grave accent mark macro to the Alt+` key (next to the "1" key); assign the acute accent mark macro to the Alt+' (single quote) key; and assign the umlaut mark macro to the Alt+u key.
Assign the macro to a shortcut key and then, when the macro plays, simply enter the base letter (see the example CaseOf commands above) in the small field on the pop up dialog. (No Enter key is needed but a Cancel button is available.) Tips and alternatives for inserting accented
characters
• EZMenu is a macro s an example of a simple menu using the Menu() command and some simple Switch() statements containing various macro commands. • From Derek Duke on WordPerfect Universe: "... free
open-source alternative [to AllChars, below] which works in much the
same way is available for those with Windows 7 or later: • From Charles Rossiter, Corel C_Tech:
• 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 alongside WordPerfect's QuickCorrect). ■ Sample macro 3
Here is a two-keystroke macro to apply UPPER case, Initial Caps, or lower case to the current word or a selection of text when a toolbar button is pushed (i.e., the second keystroke) on the pop up dialog.
Assign the macro to a shortcut key and then, when the menu appears, press "u", "i", or "l". (Or press "a" to abort.) [You can also assign the macro to a toolbar button if you prefer using a mouse.] The word(s) will then be toggled to UPPER case, Initial Caps, or lower case. (See note #1 below.) If you do not select anything before playing the macro, it will select the current word if the cursor is on, or just after, a word. Notes 1. If you have selected an all-upper case (or initial capped) word that begins a sentence, it will still have its first letter capitalized when "lower case" is chosen. (This also happens when you use the Edit, Convert Case menu in WordPerfect) 2. Note also that the word(s) will remain selected after you play the macro to let you further process the selection. If this is not desired, remove the two slash marks from the front of the SelectOff command. To copy this macro code into your WordPerfect to produce a functioning macro, see here.
Tip
■ Sample macro 4 Here is a two-keystroke macro to insert
a chosen letter's closing ("signature block") at the current cursor location. For example:
Clicking a button or pressing the letter (underlined) instantly inserts this at the cursor location: Sincerely yours,
Notice that it adds
a horizontal graphics line above the person's name to underline their
inked signature. (See the Tip below the macro code about using an image of the actual signature with the inserted text.) Basic edits: You will want to change the names ("David Smith" et al.) in the DialogAddPushbutton commands and also in the Switch commands. Tip: Assign the
macro to a key and then, when the menu appears, press the letter (preceded by a & character in the code below) to
insert the name, or just press "a" to abort. [You can also assign the macro to a toolbar button if you prefer using a mouse.] To copy this macro code into your WordPerfect to produce a functioning macro, see here.
Tip
This might be best accomplished by using a QuickWord
to insert and expand each appropriate (entire) signature block (text, spacing, and image).
For such a macro
you would delete the lines from "// Start the closing...." up to
"//Insert the name" and then use just AbbreviationExpand(<QuickWord-name-here>) in each CaseOf section of the Switch() command instead of the Type() commands used in the example. ■ Sample macro 5 This "push button" macro is by Roy ("lemoto") Lewis's macro on WordPerfect Universe at http://www.wpuniverse.com/vb/showthread.php?postid=40594#post40594. [Ed.- Code is slightly modified to adjust dialog width and button widths.]
When a button
is pushed from the
macro's main pop up dialog, this example
macro
types a word corresponding to the button's label into the document.
Hence, you will need
to modify the macro's menu and other commands in the code below (such as the
Callback/Switch routine and the branching area) to perform your own
tasks, but those familiar
with writing WordPerfect macros should have little trouble doing this. To copy this macro code into your WordPerfect to produce a functioning macro, see here. // Macro code begins here // Macro code ends here Assign the macro to a shortcut key and then, when the menu appears press the desired mnemonic key (underlined letter) for a "two key" macro, or click the push button.■ Additional sample macros See Footnotes below.
[Page Top]
|
|||
Footnote 1 [Referenced in Sample #4 above...]
Explanation
WordPerfect's built-in conversion to all lower case (e.g., Edit, Convert Case, Lower case — or the macro equivalent, ConvertCaseLowercase) still leaves the first word of every sentence capitalized, so if you have large blocks of text and you want all of it to be in lower case, either of the following macros should do the job. Tip
UPDATE: For WordPerfect X9 (released in 2018) and later versions you can use Edit, Convert Case, Lower case since now it will convert ALL characters in your selection of text to lower case. But the methods below might still be useful (adapted to your needs) when you want to "step" thought a large block of text, a character at a time. [Always make a backup of your document first. To copy a macro from an Internet site (like this one) see here.] The first macro is a "brute force" approach that looks at each character in the selection and, if it is upper case, it converts it to lower case, then it proceeds to the next character. It stops when it encounters a user-defined "terminator" character (here, the Greek omega symbol "Ω"; all WordPerfect symbols are seen as "characters" by macros). The second (and newer) macro is more elegant since it first converts the selection to lower case using the built-in command, ConvertCaseLowercase; then it removes remaining upper case letters with a Search/Replace routine (which uses a 2-dimension array). One virtue of these approaches is that they preserve all existing formatting, since they only change upper case characters to lower case characters, skipping over any formatting codes. [A small, three-command macro that can do the same thing and remove all formatting at the same time was posted by Roy ("lemoto") Lewis on 02/24/09 in the Corel WPX4 newsgroup: SelectAll vT = ToLower(?SelectedText) Type(vT).] The general methods used might be useful in other macros. Important
This macro uses a Greek omega
"Ω" character (the same as WordPerfect symbol 8,50) where indicated below. This character is used as a "terminator" to
tell the macro when to stop processing.
You can use any character symbol that is not used elsewhere in the document. (If it comes from the WordPerfect symbol sets (Ctrl + w) be sure to enclose it in double quote marks since WP symbols are characters.) The omega character, converted from its numerical value with the macro command NToC, was an arbitrary choice for this macro on the assumption it probably would not exist in most users' documents. It might take some time to finish converting characters in a very large document and/or on some systems. You should see its progress in the WordPerfect status bar. You can always stop it by right-clicking the WordPerfect "cassette" icon in your system tray at the bottom right of your desktop. [Sample macro #6 below is probably faster in must situations.] [To copy this macro code into
your WordPerfect, see here.]
// Macro code begins here: Like the previous macro, this
macro will convert the current word — or everything in a selection of
text — to lower case, including capitalized words at the
beginning of every sentence, the pronoun "I," etc.
[To copy this macro code into your WordPerfect, see here.] // Macro code begins here: [Page Top]
Footnote 2 [...Continued from above:] ■ Sample macro 8
Here is a demonstration macro using a push button menu that uses 36 buttons to represent the keyboard's a-z keys and the 1-0 keys. Note that this macro simply displays a confirmation message when any of the 36 keys are pressed -- otherwise it does nothing useful. It is a demonstration macro to help you with the macro's structure and command syntax. However, you can replace the various Messagebox() commands in the macro code below with appropriate commands for your tasks. [To copy this macro code into your WordPerfect, see here.] // Macro code begins here // Purpose: Demonstrate a pop up menu with multiple push buttons (a-z; 1-0). The buttons can be activated with a key press or with a mouse click, and the menu then immediately disappears, replaced by a confirmation Message. OnCancel(EndIt@) vTitle:="--DEMO--> 36 choice menu" vTxt1:="Please type (or click on) a letter or number:" vTxt2:="( or press Esc or Alt + F4 )" // Display a "push button" menu: DialogDefine ("Menu";50;50;230;110;Percent!;vTitle) DialogSetProperties ("Menu";FontName:"Arial") DialogAddText ("Menu";"Txt1";5;5;240;14;Left!;vTxt1) // Add buttons in 3 rows on the dialog: DialogAddPushButton ("Menu";101;15;20;12;14;0;"&a") DialogAddPushButton ("Menu";102;30;20;12;14;0;"&b") DialogAddPushButton ("Menu";103;45;20;12;14;0;"&c") DialogAddPushButton ("Menu";104;60;20;12;14;0;"&d") DialogAddPushButton ("Menu";105;75;20;12;14;0;"&e") DialogAddPushButton ("Menu";106;90;20;12;14;0;"&f") DialogAddPushButton ("Menu";107;105;20;12;14;0;"&g") DialogAddPushButton ("Menu";108;120;20;12;14;0;"&h") DialogAddPushButton ("Menu";109;135;20;12;14;0;"&i") DialogAddPushButton ("Menu";110;150;20;12;14;0;"&j") DialogAddPushButton ("Menu";111;165;20;12;14;0;"&k") DialogAddPushButton ("Menu";112;180;20;12;14;0;"&l") DialogAddPushButton ("Menu";113;195;20;12;14;0;"&m") DialogAddPushButton ("Menu";114;15;40;12;14;0;"&n") DialogAddPushButton ("Menu";115;30;40;12;14;0;"&o") DialogAddPushButton ("Menu";116;45;40;12;14;0;"&p") DialogAddPushButton ("Menu";117;60;40;12;14;0;"&q") DialogAddPushButton ("Menu";118;75;40;12;14;0;"&r") DialogAddPushButton ("Menu";119;90;40;12;14;0;"&s") DialogAddPushButton ("Menu";120;105;40;12;14;0;"&t") DialogAddPushButton ("Menu";121;120;40;12;14;0;"&u") DialogAddPushButton ("Menu";122;135;40;12;14;0;"&v") DialogAddPushButton ("Menu";123;150;40;12;14;0;"&w") DialogAddPushButton ("Menu";124;165;40;12;14;0;"&x") DialogAddPushButton ("Menu";125;180;40;12;14;0;"&y") DialogAddPushButton ("Menu";126;195;40;12;14;0;"&z") DialogAddPushButton ("Menu";127;15;60;12;14;0;"&1") DialogAddPushButton ("Menu";128;30;60;12;14;0;"&2") DialogAddPushButton ("Menu";129;45;60;12;14;0;"&3") DialogAddPushButton ("Menu";130;60;60;12;14;0;"&4") DialogAddPushButton ("Menu";131;75;60;12;14;0;"&5") DialogAddPushButton ("Menu";132;90;60;12;14;0;"&6") DialogAddPushButton ("Menu";133;105;60;12;14;0;"&7") DialogAddPushButton ("Menu";134;120;60;12;14;0;"&8") DialogAddPushButton ("Menu";135;135;60;12;14;0;"&9") DialogAddPushButton ("Menu";136;150;60;12;14;0;"&0") // Tip:
// The next DialogAddPushButton() command creates an "active" Cancel button on the menu -- i.e., when the Enter key is pushed the macro is canceled because the button is marked as a default button. // To make it "passive" -- i.e., where you must deliberately click on that menu button with your mouse (alternative: press the Esc or Alt+F4 key) to cancel the macro -- remove both the "DefaultBttn!" and the "|" from the command's parameter. DialogAddPushButton ("Menu";199;90;90;40;14; DefaultBttn! | CancelBttn!;"Cancel") DialogAddText ("Menu";"Txt2";135;93;90;14;Left!;vTxt2) DialogShow ("Menu";"WordPerfect";199) // Store the menu choice and use it in the Switch command: vAns:=MacroDialogResult Switch(vAns) CaseOF 101: Messagebox(;;"You chose button [ a ]") CaseOF 102: Messagebox(;;"You chose button [ b ]") CaseOF 103: Messagebox(;;"You chose button [ c ]") CaseOF 104: Messagebox(;;"You chose button [ d ]") CaseOF 105: Messagebox(;;"You chose button [ e ]") CaseOF 106: Messagebox(;;"You chose button [ f ]") CaseOF 107: Messagebox(;;"You chose button [ g ]") CaseOF 108: Messagebox(;;"You chose button [ h ]") CaseOF 109: Messagebox(;;"You chose button [ i ]") CaseOF 110: Messagebox(;;"You chose button [ j ]") CaseOF 111: Messagebox(;;"You chose button [ k ]") CaseOF 112: Messagebox(;;"You chose button [ l ]") CaseOF 113: Messagebox(;;"You chose button [ m ]") CaseOF 114: Messagebox(;;"You chose button [ n ]") CaseOF 115: Messagebox(;;"You chose button [ o ]") CaseOF 116: Messagebox(;;"You chose button [ p ]") CaseOF 117: Messagebox(;;"You chose button [ q ]") CaseOF 118: Messagebox(;;"You chose button [ r ]") CaseOF 119: Messagebox(;;"You chose button [ s ]") CaseOF 120: Messagebox(;;"You chose button [ t ]") CaseOF 121: Messagebox(;;"You chose button [ u ]") CaseOF 122: Messagebox(;;"You chose button [ v ]") CaseOF 123: Messagebox(;;"You chose button [ w ]") CaseOF 124: Messagebox(;;"You chose button [ x ]") CaseOF 125: Messagebox(;;"You chose button [ y ]") CaseOF 126: Messagebox(;;"You chose button [ z ]") CaseOF 127: Messagebox(;;"You chose button [ 1 ]") CaseOF 128: Messagebox(;;"You chose button [ 2 ]") CaseOF 129: Messagebox(;;"You chose button [ 3 ]") CaseOF 130: Messagebox(;;"You chose button [ 4 ]") CaseOF 131: Messagebox(;;"You chose button [ 5 ]") CaseOF 132: Messagebox(;;"You chose button [ 6 ]") CaseOF 133: Messagebox(;;"You chose button [ 7 ]") CaseOF 134: Messagebox(;;"You chose button [ 8 ]") CaseOF 135: Messagebox(;;"You chose button [ 9 ]") CaseOF 136: Messagebox(;;"You chose button [ 0 ]") Endswitch // Exit here: Label(EndIt@) Return // Macro code ends here [Page Top]
|