Skip to content

Settings: Macros

Macros

Macros allow you to extend keyboard shortcuts and create custom functionality assigned to a shortcut. They can be configured on three hierarchy levels - User Settings, Show Settings and Global Settings - which define their scope and priority.

Macro Hierarchy

Erizos Studio supports a hierarchical macro structure:

Level Description Priority
User Macros Defined for the current user. Override any Show-level and Global macros with the same shortcut. Ideal for personal workflow customization. Highest
Show Macros Defined within a specific show configuration. Used for show-specific actions or triggers. Overrides any Global macros with the same shortcut. Medium
Global Macros Available system-wide for all users and shows. Typically used for shared operations or maintenance routines. Lowest

Note

Priority is resolved by shortcut, not by name. When you press a key, Studio walks the User, then the Show, then the Global list and runs the first macro whose shortcut matches - the rest are ignored. The text in the Macro column is a free-text title and has no effect on which macro runs.

Info

The Show Macros tab only appears while a show is open. Global Macros live under Global Settings, which on a Studio Server is only available to administrators; changing them does not require a Studio Server restart.

Creating a Macro

  1. Go to Settings → Macros (either under the 'User' subsection, or under the 'Show', or in 'Global Settings')
  2. Click +
  3. In the Shortcut field, press the key or key combination you want to assign
  4. Type a name for the macro in the Macro column
  5. Click the macro's row to select it, then write the macro script in the Macro Editor on the right
  6. Click Save Settings to apply the changes

Note

The Macro Editor is read-only until a row is selected. Press Esc to deselect the row again.

Interface of the Macros Tab

Macros

Icon Action Description
Import Macros Click the Import icon and select a .ezmacros file to import macros. If the list is not empty you are asked "Are you sure you want to overwrite existing macros?" - the imported file replaces the current list
Export Macros Click the Export icon to save the current list as Macros (YYYY-MM-DD).ezmacros
Copy Macros Copy the selected macros to the macros clipboard
Paste Macros Paste the copied macros into the current list - use this to move macros between the User, Show and Global levels. Disabled while the clipboard is empty
Toggle Edit Show the selection checkboxes so that several macros can be copied or removed at once
Remove Macros Delete the selected macros, after confirming "Remove Macros?"
Add Macro Click to create a new Macro
Filter Click the Filter icon and type a keyword - the current list is narrowed to the macros whose script text contains that word

Info

An .ezmacros file is a JSON file carrying the format marker erizos.macros, its version and the list of macros (shortcut, title, command). A file without that marker is refused with "Invalid macros file format"; a file written by a newer version asks you to confirm before it is loaded.

Writing a Macro

A macro body is UI Builder script code - the same TypeScript/JavaScript environment and the same Api object used by a UI Builder user interface. For example:

1
2
await Api.playlist.readPage('1005');
await Api.profile.takeIn();

See the UI Builder API reference for everything the Api object exposes.

Note

Every UI Builder user interface saved as a Library (Macro) is automatically referenced by every macro, so shared helper functions can be kept in one place.

Warning

Macro execution is time limited: a macro may block for 1 second and must finish within 2 seconds. Long-running work belongs in a UI Builder user interface, not in a macro.

Page Macros Examples

The Api.playlist.createPage and Api.playlist.createPages methods support flexible template referencing. A template can be specified in the following ways:

Format Example Description
ID template: '6943b59863e271273a05e137' Reference a template directly by its unique ID
Name template: 'MY_COOL_NAME' Reference a template by its display name
Path template: '/SOME/AWESOME/PATH' Reference a template by its file system path
Object template: { name: '...', layer: '...' } Reference a template by name scoped to a specific layer
Object with system template: { path: '...', system: 'COMPOSER' } Reference a template by path, filtered by render system

Info

A string reference may also carry a layer id after a vertical bar, for example:

template: 'MY_COOL_NAME|5e7fa753-6160-4b1c-a1bd-0f10e1315609'

A string that is a valid ID is used as the ID. Otherwise it is matched against the template path first and then against the template name; both comparisons ignore case.

Besides template, a page may set num (a number or a string), name, description, channel and color.

Using the system field

The system field is useful when templates from different render engines share the same name - for example, a Singular template and a Composer template both named "Weather". By specifying system, the macro first filters by render engine, then matches by name or path, ensuring the correct template is resolved.

Example 1 - Create a single page using a template ID

await Api.playlist.createPage({
  template: '6943b59863e271273a05e137',
  name: 'CREATED_FROM_MACROS #1',
  description: 'Main election results page',
  color: '#FF5733',
  num: 9999
}, { after: 1005 });

The page is inserted after the page numbered 1005. The template is identified by its unique MongoDB ObjectID.

Example 2 - Create multiple pages using different template reference formats

await Api.playlist.createPages([
  {
    template: {
      name: 'Demo Composition',
      layer: '5e7fa753-6160-4b1c-a1bd-0f10e1315609'
    },
    name: 'CREATED_FROM_MACROS #2',
    description: 'Second results breakdown',
    color: '#2ECC71',
    num: 9998
  },
  {
    template: {
      path: '/Users/a1/Desktop/ElectionTable_Ver05_ograf_v1/BlueBook_Ver03_ograf-v1',
      system: 'COMPOSER'
    },
    name: 'CREATED_FROM_MACROS #3',
    description: 'Summary page',
    color: '#9B59B6',
    num: 9997
  }
], { before: 1000 });

Both pages are inserted before the page numbered 1000.

  • Page #2 uses a template object with name and layer - useful when multiple templates share the same name across different layers.
  • Page #3 uses a template object with path and system: 'COMPOSER' - the macro resolves the template exclusively within the Composer render engine.

Note

The after and before values are matched against the page number. A value that is not numeric is treated as a playlist item id instead. If no item matches, the new pages are appended at the end of the playlist.

createPage returns the created page and createPages returns an array in the same order as the input. An entry is undefined when its template could not be resolved, so the result can be checked to find the references that failed.