A macro consists of keystroke sequences that are recorded, saved, and executed either manually, via a key binding, or with an event trigger. When the macro is invoked, the recorded keystrokes and instructions execute. Only keystrokes (not mouse movements) are recorded within macros. Note that, with the exception of the Find dialog box, macros that call external dialog boxes are not supported. Macros are stored in projects or the Toolbox. Custom key bindings can be assigned to macros.
The Macros toolbar provides quick access for recording, running, and saving macros. To open or close the toolbar, select View|Toolbars|Macros. Alternatively, select Tools|Macros.
Macros can be created via recording keystrokes, or by programming macro commands in the Macros properties dialog. For information about programming macros, refer to the Macro API.
Recording is a simple method for creating a macro. Recording a macro requires typing a series of keystrokes in the Editor Pane. To record a macro:
Alternatively, use the Macros Toolbar to invoke the commands.
To save the most recent macro:
Use the "New Macro" Properties dialog box to program macros in either Python or JavaScript. Additionally, use this dialog box to specify macro key bindings and Komodo triggers that invoke the macro automatically.
To add a macro:
Refer to the Macro API for information about programming macros.
To run the most recently recorded macro, select Tools|Macros|Execute Last Macro, or use the associated key binding. If the Macro Toolbar is open (View|Toolbars|Macro), click Macro: Run Last Macro.
To run a macro that has been saved to a file and assigned to a project or to the Toolbox, double-click the macro, or use the key binding assigned to the macro. Alternatively, right-click the macro in the Projects tab or the Toolbox and select Execute Macro from the context menu.
Macros can be configured to execute based on certain Komodo events or triggers. When an event occurs (for example, a file is opened in Komodo), the macro is triggered and then executes. A macro that triggers "editor" functions or modifies open files should run in the foreground to block user access to the editor. Macros running in the foreground run and "block" until they return. This prevents the user from moving the cursor and disrupting the macro currently in progress.
Macro Return Values
Use the Macros Properties dialog box to specify a macro return
value. Entering return 1;
is syntactically valid as
a true value in either Python or JavaScript. Macros that return
true and invoke before a Komodo event can interrupt the
process under execution. For example, a macro can prevent a file
from being saved if true is returned. If a macro returns "None"
in JavaScript, or "Null" in Python, it evaluates to false and
does not interrupt the Komodo event in progress.
Note: Be sure to enable macro triggers via the Projects and Workspace Preferences in Komodo's preferences. In the Triggering Macros area, select Enable triggering of macros on Komodo events, and then click OK.
To add a trigger to a macro:
If a macro is not associated with a Komodo event, it can run either in the foreground or in the background. Depending on the use case, some macros should run in the background while others are more suitable for running in the foreground. Macros that invoke and do not affect the current file are best run in the background to minimize interference with Komodo responsiveness. Macros that perform "editor" functions or modify open files should always run in the foreground to "block" and prevent user interference. This prevents the user from moving the cursor and disrupting the macro currently in progress. Macros that run in the background are run in threads in Python, or in a timeout in JavaScript.
To run a macro in the background:
Macros are added to the Toolbox via the Tools|Macros|Save to Toolbox option. However, you can manually add macros to the Toolbox, or to a project in the Projects tab.
To add a new macro to a project or the Toolbox:
Alternatively, existing macros can be dragged and dropped between the Toolbox and the Projects tab.
To access macro options, right-click the macro name in a project or the Toolbox and select the desired option.
libz
(for example WinZip). The Export
Package option differs from the Export as
Project File option in that copies of filesystem-based
components (such as files and dialog projects) are included in
the archive. Conversely, Export as Project
File creates a project with a reference to the
component's original location and does not create copies of the
components. When Export Package is invoked,
you are prompted for a name and file location for the package.
Exported packages can only be imported into "container" objects
in Komodo, such as projects, the Toolbox, and folders within
projects and the Toolbox. See Toolbox - Exporting and
Importing Toolbox Contents, Projects - Importing
and Exporting Projects via Packages, Folders - Import
Contents from Package for more information.The default macro icon can be replaced with custom icons. Komodo includes more than 600 icons; alternatively, select a custom image stored on a local or network drive (use 16x16-pixel images for best results).
To assign a custom icon to a macro:
To revert to the default icon for a selected macro:
Custom key bindings can be assigned to macros stored in the Toolbox or in a Project. Use the Key Binding tab in the macro's Properties to specify the keystrokes that invoke the macro. See Key Bindings for Custom Components for more information.
Komodo's Vi emulation offers a command-line mode. Entering ':' opens a text box for entering commands. You can add additional commands by creating a Toolbox folder named Vi Commands, then creating Macros with the name of the desired command. The macro is executed when you type it's name in the Vi command text box. For example, to create a macro that replicates the behavior of the 'ZZ' command in Vi: