To run a macro in the Scripting Editor, right-click the macro in the Scripting Project tree and select the command Run Macro.
There are different ways to run a macro from Authentic Desktop:
|Via the Tools | Macros menu of Authentic Desktop.|
|By creating and using a toolbar button for a macro.|
|By creating and using a menu item for a macro.|
Note that only one macro can be run at a time. After a macro (or event) is executed, the script is closed and global variables lose their values.
The Tools | Macros menu command (screenshot below) opens a submenu containing the macros defined in the Scripting Project that is currently active in Authentic Desktop. The active Scripting Projects are specified in the Scripting tab of the Options dialog, or in the Scripting tab of the project settings.
From the submenu of available macros, select the macro to run. The macro will be executed.
You can create an icon in the toolbar or a menu item that runs a selected macro. To do this, click Tools | Customize | Macros. This causes the Customize dialog to be displayed (screenshot below).
Now do the following:
|1.||In the Macros tab of the Customize dialog, select the required macro from the Macros pane. The macros in the Macros pane are those in the active Scripting Project (which is specified in the Scripting tab of the Options dialog).|
|2.||In the Display Text input field enter the name of the icon. This name will appear when the cursor is placed over the icon when it is in the toolbar.|
|3.||Click Add Command to add it to the list of commands.|
|4.||Select the command and click Edit Icon to create a new icon.|
|5.||Drag the finished icon from the Associated Commands pane and drop it on to the toolbar or menu when the cursor changes from an arrow to an I-beam or line.|
|6.||Macros can even be assigned their own shortcuts in the Keyboard tab of the Customize dialog (see screenshot above).|
To remove the toolbar icon, open the Macros tab of the Customize dialog and drag the icon out of the toolbar and into the Associated Commands pane. Select the command in the Associated Commands pane and click Remove to remove the command from the pane.
The XMLSpy API includes a function, AddMacroMenuItem(), to add macros as menu items to the Tools menu. This function can be used to add one or more macros to the Tools | Macros list of macros. Typically, you should do this as follows:
|1.||Add the macro menu item by calling the XMLSpy API function, AddMacroMenuItem().|
Application.AddMacroMenuItem("DeleteElements","Delete Elements Dialog");
|The function's first parameter (DeleteElements in the example listing above) is the name of the macro. If you run the macro and there is an open project having scripts associated with it, Authentic Desktop searches for the macro in the project scripts first. |
If there are no project scripts, or if Authentic Desktop cannot find the macro, then it looks for the macro in the global scripts.
|The second parameter (Delete Elements Dialog) is the display text for the menu item.|
|2.||Reset the Tools menu by calling ClearMacroMenu(). This removes all previously added menu items|
The best way to call these two functions is with the Autorun macro of the global scripting project or the On_OpenProject event.
(C) 2019 Altova GmbH