User-defined macros

HoTMetaL PRO's macro facility lets you create macro `hot keys' (accelerators) that carry out a series of actions.

Macros can be associated with text and/or elements to be inserted in a document, a single command, or a complex series of commands. Some actions that you can perform with macros are:

Creating macros

The actions associated with creating (recording) a macro are as follows:

The progress message area of the main window displays the phrase Recording macro while a macro is being recorded. The usual messages like Opening... will show up when appropriate, but any time the message area would normally be empty, it will instead say Recording macro.

Now you will get a dialog box that lets you select a name and an accelerator for the macro. The macro name is to help you identify the macro in the list in the dialog box that appears when you choose the Run Macro... command. The accelerator is the sequence of keystrokes that will run the macro.

MACRO

An accelerator can consist of any choice from the drop-down list labelled Key (a letter, number, function key, or arrow key), alone or preceded by Ctrl, Meta and Shift in any combination.

To include Ctrl, Meta, or Shift in the accelerator, click on the appropriate check box. (The Meta Key is generally the key to the left of the spacebar on many keyboards this key is labeled Alt.)

If you re-use one of HoTMetaL PRO's built-in keyboard accelerators as a macro accelerator, its original functionality will be unavailable as long as that macro is loaded. You will get an error message if you attempt to use an accelerator that has already been used for another macro.

Macros involving toolbar buttons

If you use a button from one of the `HTML' toolbars when recording a macro, note that even though a toolbar button can perform one of several actions (insert, change, split) only the action that was actually performed when you recorded the macro will be performed the next time you run the macro. For example, if the insertion point is inside a P element and you click on the PARAICON button, HoTMetaL PRO will split the P element. This action is recorded in a macro as `split the current element', so when the macro is run, it will attempt to split the current element, even if it's not a P. (By contrast, if you create markup with the Insert Element... or Change Element... command, it will be played back in the macro exactly as you entered it.)

Restrictions

A macro should be self-contained, that is, its completion must not depend on any user input at the time the macro is run, such as typing in a text entry box in a dialog box or making a selection from a list. Consequently, there are some sequences of actions that cannot successfully be included in a macro. As a general guideline, if a macro involves invoking any of the commands whose name ends in `...', that command should be completed somewhere in the macro. So, for example, you can define a macro that inserts a particular element, but you cannot define a macro that simply brings up the Insert Element dialog box.

Mouse clicks in the document window are ignored during macro recording. The first time you attempt to use the mouse to change the selection, HoTMetaL PRO will beep. The second time, you will get a message saying that you should use the cursor (arrow) keys to change the selection.

Spell checking operations should also not be put in a macro.

Changing the accelerator

To change a macro accelerator, choose Edit Macros... in the Special menu. This command gives you a dialog box with a list of currently loaded macros.

Click on the name of the macro that you want to change. This causes the name and accelerator of the macro to appear in the controls at the top of the box.

Once you've done this you can change the accelerator for the macro by means of the Meta, Shift, and Alt check boxes and the Key option menu.

When you have made the desired changes, click on the [Edit Macro] button.

Deleting a macro

Edit Macros... also lets you delete a macro from the list of available macros. Highlight the macro in the list and click on the [Delete] button. If you delete a macro that has been loaded from a file, the macro is removed only from HoTMetaL PRO's list of available macros-it is not deleted from the file from which it was loaded, and can subsequently be re-loaded. You can delete only one macro at a time.

Running a macro

The usual way to run a macro is to type its keyboard accelerator. You can also run macros using the Run Macro... command in the Special menu. This command gives you a dialog box that lists all the macros that are currently available. This list includes macros that have been loaded from a file and those that have been defined in the current session but not saved to a file. If a macro file is loaded, the dialog box displays the filename.

To run a macro:

HoTMetaL PRO will carry out the series of operations associated with the macro. You can run only one macro at a time.

Macro options

You can set where a macro file is to be saved and what extension the macro dialog box will look for in the Extensions/Paths section of the Options dialog box. The default directory is the macros directory under the HoTMetaL PRO directory, which you can change by typing in the path to the file, or by clicking on the [Choose File] dialog box. The default extension for macro files is .mcr, but you can change it if you like.

Saving macros to a file

Choose Save Macros... in the Special menu to save the currently loaded macros to a file. A macro file saved in this way can later be loaded using the Load Macros... command. The file saving dialog box will come up with the directory that is specified in the Options dialog box.

If any macros are still unsaved when you attempt to exit HoTMetaL PRO, you will get a warning message informing you of this and giving you the opportunity to save the macros before exiting.

Loading a macro file

Choose Load Macros... in the Special menu to load a macro file. The file saving dialog box will come up with the directory that is specified in the Options dialog box.

After a macro file is loaded, the previously loaded macros are unavailable. If any macros have been defined but not yet saved, these will be lost. Before the new macro file is loaded, you will receive a warning dialog giving you the opportunity to save any unsaved macros.

When you load a macro file, it becomes the default macro file and will be loaded the next time you launch HoTMetaL PRO. The default macro file for HoTMetaL PRO is hmpro3.mcr, located in the macros directory under the HoTMetaL PRO directory.

Macros are not associated with a specific document, so any macros you load will be available for use with all files that you are editing in the current HoTMetaL PRO session.