November
1997: Using WordPerfect Dialogs in Your Macros WordPerfect
includes a set of macro commands that display WordPerfect's own dialog boxes during your
macro. When you play a macro with a dialog box command in it, the dialog box will display
on the screen until the user provides input and dismisses the dialog box. Then the next
command in the macro will be executed.
But in some cases you may want the macro to interact with the dialog box before the
user does. For instance, you may want to make sure a certain check box is checked.
To successfully use WordPerfect dialogs in your macro, there are a few commands you
should be familiar with. These are InhibitInput, InvokeDialog, and CoachAnimate.
Another command, SendKeys, can also be used, but I won't cover that command here.
The InhibitInput Command
Normally, user input during a macro (except during a PAUSE command or when a
dialog box is waiting for user input) is ignored while a macro is playing. The InhibitInput
command can be used to allow interaction with the dialog while the macro is playing. When
you use this command, the macro itself can simulate keystrokes, just as though the user
had performed them, using the CoachAnimate or SendKeys command.
The InhibitInput command has one parameter called State, with two
possible states: Off! and On!. The default is InhibitInput(On!). When
InhibitInput is on, the macro is suspended while the dialog is displayed, and
doesn't continue until the dialog is dismissed by the user. If InhibitInput is off,
the macro can send keystrokes via the CoachAnimate command to a dialog box. (Any
clicks or keystrokes the user performs will also be allowed.)
In order for InhibitInput to be effective, you should display the dialog with
the InvokeDialog command.
The InvokeDialog Command
The InvokeDialog command is a product command used to open a WordPerfect dialog
on the screen. Normally, when you use a dialog command without InvokeDialog, such
as BulletDlg, the macro displays the dialog, then pauses to allow the user to
interact with that dialog. When the user dismisses the dialog, the macro will continue.
Thus, the macro cannot actively interact with the dialog.
If you need the macro to interact with a dialog, however, you must open the dialog in a
way that will not cause the paused condition to occur. This is where the InvokeDialog
command comes in. When you open a dialog with the InvokeDialog command, the macro
does not pause, and additional macro commands can interact with that dialog.
The InvokeDialog command has one parameter. The normal dialog command to open
the dialog you need is inserted in this parameter. For example,
The CoachAnimate Command
The CoachAnimate command was created to allow the WordPerfect Coaches to
automatically animate the mouse pointer to various locations on the screen, or to
automatically simulate keystrokes. You can also use it to interact with dialogs, toolbars,
or other WordPerfect screen objects in your macros.
Since sending keystrokes or mouse movements and clicks with CoachAnimate
simulates a person doing the same thing, you should include an InhibitInput(Off!)
command prior to a CoachAnimate command to allow the commands to go through.
You can use CoachAnimate to simulate keystrokes or mouse movements. To specify
which type you wish to use, place one of the following in the Type parameter.
Keyboard!: With this type, you can send keystrokes to the dialog. The keystrokes
are specified in the Specification parameter.
Mouse!: With this type, you can animate the mouse pointer to a specific place on
the dialog. You'll need specify the region name of the location on the dialog that you
want to interact with in the Specification parameter.
In the Specification parameter, you will specify what keys or movements you want
to take place. If you choose the Keyboard! Type, the Specifications
parameter will include keystrokes.
If you choose the Mouse! Type, you'll specify an action and a named region that
the action should work on.
Here's an example of using these commands in a macro. This example opens the Margins
dialog, moves among the various entry windows, then sets the left margin to 1.5 inches.