Example Scripting Project
A demo project that illustrates scripting with Authentic Desktop is available at the following path: C:\Users\<user>\Documents\Altova\Authentic2025\AuthenticExamples\SampleScripts.asprj. This scripting project consists of a few macros and a Windows form.
To load the scripting project into Scripting Editor:
1.On the Tools menu, click Scripting Editor.
2.Click Open and browse for the SampleScripts.asprj file from the path above.
The project contains several macros in the "Macros" directory.
Macro | Description |
AddMacroMenu | This macro adds a new menu item to Authentic Desktop, by invoking the Application.AddMacroMenuItem method of the COM API. The first argument of the AddMacroMenuItem method is the name of the macro to be added (in this example, "CloseAllButActiveDoc") and the second argument is the display text for the menu item.
Whenever this macro is run, a new menu command called "CloseAllButActiveDoc") is added under the Tools menu. To clear macro menu items created previously, either restart Authentic Desktop or create a macro that calls the Application.ClearMacroMenu API method. |
CloseAllButActiveDocument | When executed, the macro iterates though the currently open documents in Authentic Desktop and closes all of them, except for the active document. |
SearchPath | This macro displays a form that lets users perform search for files within the current project. The form is available in the "Forms" directory, where you can view its design and the associated event handlers.
The GetAllPathsFromProject() method returns all the file paths that belong to the currently opened project, as an array. The definition of this method is in the GlobalDeclarations script of the project. The InsertStringInArrayUnique method ensures that only unique paths are added to the array. Next, the form is initialized with CreateForm. Finally, the array is converted to a .NET type with the help of the CLR.Create method and the form is populated with the resulting ArrayList collection.
The Open button of the form has a handler that calls the Application.Documents.OpenFile API method to open the currently selected file. |
To enable the scripting project as global Authentic Desktop scripting project:
1.On the Tools menu, click Options.
2.Click the Scripting tab.
3.Under "Global scripting project file", click Browse and select the SampleScripts.asprj file from the path above.
4.This scripting project does not have auto-macros and application event handlers; therefore, you don't need to select either the Run auto-macros... or Process events check boxes.
5.Click Apply.
At this stage, several new menu items (one for each macro) become available under the Tools | Macros menu.
To run the "SearchPath" macro:
1.Open an Authentic Desktop project that contains several files (in this example, C:\Users\<user>\Documents\Altova\Authentic2025\AuthenticExamples\Examples.spp).
2.On the Tools menu, click Macros, and then click Search Path.
3.Type the search term (in this example, ".xml").
As shown above, all file names that contain the search term are now listed. You can click any element in the list, and then click Open to display it in the main editor.