Developing Extensions

Script based application extensions can be made in two possible levels of complexity - snippets and extensions. Snippets are a simple form of extension that consists of a relatively short script that can be invoked with a single entry in the application's File menu. Full extensions on the other hand can access a number of additional facilities, such as storing persistent settings and defining any number of global or context menu entries.

Finally, it is also possible to directly execute script commands by using the console (ViewOpen Console).

Have a look at the Extensions and Snippets Forum Category for examples. The API reference lists the APIs that are available on top of the standard ECMA script v3 functionality.

Creating a Snippet

  1. Open the application settings (AspectSettings on macOS and FileSettings on other systems)
  2. Go to the ExtensionsSnippets page
  3. Click Add Snippet…
  4. Enter a caption for the menu entry of the new snippet
  5. Write the script for the snipped in the “Source Code:” field

If you want to publish your snippet for others to use, the snippet should start with a single-line comment that contains the caption for the menu entry. When pasting the source code during snippet installation, this will be used to pre-fill the “Menu entry:” field.

For publishing a snippet you can then simply create a new topic in the Extensions and Snippets Forum.

Creating a Minimal Extension

Each extension has its own folder in which it can store any required resources and the required "extension.js" file. The folder should be named like the identifier used to access the extension programmatically.

At the global scope of extension.js, the extension should perform any basic setup that it needs. This includes a call to registerExtension, and registering any actions or events that it supports. A simple example could look like this:

// This call must be done before any other calls. The first argument must be a
// unique identifier of the add-on and should include the creator's name in some
// form. It must be a valid JavaScript identifier.
registerExtension("com.superplugins.example", {
	version: "1.0.0",
	title: "Example Extension",
	vendor: "Superplugins Inc.",
	description: "Adds a menu entry for displaying a message box."
})

registerAction("showMessageBox", function() {
	print("Now showing the message box...");
	alert("This is the message!", "Message Addon");
});

addMenuEntry("showMessageBox", "Show message box", "control+alt+M")