Skip to content

Macro Action

The Macro actions allows the execution of macros or custom code.

Option Description
Title If configured, will set the title/text on the button. This will override any other text that would normally be displayed.
Icon Override Url to a custom icon. If configured, this will override any icon that would normally be displayed.
Macro Selection Sets how to select the macro:
-Hotbar: Select macros from the macro hotbar.
-Select by Name/Id: Select macros using their name or ID.
-Execute Code: Execute code directly.
-All others: List of macros to select.
Mode (Hotbar only) Hotbar selection mode:
-All Hotbar Pages: Select a macro from any hotbar page.
-Visible Hotbar Page: Select a macro from the currently visible hotbar page.
Macro Nr (Hotbar only) The macro to select from the hotbar.
All Hotbar Pages: Value between 1 and 50, where 1-10 corresponds with macros on the 1st page, 11-20 corresponds with macros on the 2nd page, etc.
Visible Hotbar Page: Value between 1 and 10, where the value corresponds with macros on the currently visible page.
Macro Name/ID (Select by Name/ID only) The name or ID of the macro to select. This is case sensitive and must match exactly.
Arguments (All but Execute Code) Arguments for the macro, see here.
Code (Execute Code only) Code to run. This is normal JavaScript code.
Display -Name: (All but Execute Code) Display the name of the macro on the Stream Deck.
-Icon: (All but Execute Code) Display the icon of the macro on the Stream Deck.
-Border: Display a border of a specified color on the Stream Deck
Colors -Border: A border is drawn on the Stream Deck of this color if Border is ticked in the Display section.
-Background: Background color of the button.

Macro Arguments

Macro arguments allow some customization and expandability of macros. For more information on using macro arguments, read the 'Script Macro Arguments' section on the official Foundry documentation.

Macro arguments must be stringified JSON objects, for example:

{"argument1":value1, "argument2":value2, etc}
Which can then be accessed within the macro as scope.argument1 and scope.argument2.

For example, take the following script macro to move the selected token to coordinates x and y:

token.document.update({x: scope.x, y: scope.y})
If you want to call this macro from the Stream Deck to move the token to x=1000 and y=1500, you'd use the following arguments:
{"x":1000, "y":1500}
Please note that you must include the quotation marks around the object keys.

Changing Button Icon and Text

Besides all standard Foundry functionality, you can also edit the text and icon of the button you pressed to run the macro.

Some examples:

To change the text of the button, add the following to your macro:

scope.button?.setTitle("New Title")

To change the icon of the button, add the following to your macro:

scope.button?.setIcon("path/to/icon.png")

To change both the text and icon of the button, add the following to your macro:

scope.button?.set("New Title", "path/to/icon.png")

You can add an options variable to the setIcon and set functions for additional options:

const options = {
    background: "#FF0000",  //adds a red background
    border: true,           //adds a colored border
    borderColor: "#00FF00"  //sets the border to green
}
scope.button?.setIcon("path/to/icon.png", options)

See here for all options.