Script events
Script initialization event
The script initialization event is triggered when the script is loaded, either when Stream Deck starts or when a profile/page/folder with the button/dial is loaded. The primary purpose of the init event is to prepare an image and text on the button/dial, but any action can be executed.
Incoming Midi events
For incoming Midi events, all commands triggered by the event are run. If an incoming midi event triggers multiple commands, they are executed in the order they appear in the script.
The plugin monitors both midi commands sent from your daw and commands sent from Stream Deck buttons.
Press/release events
The order of (press)/(release) commands is important. When the button is pressed and released, the commands will be executed in the order they appear in the script.
The plugin can operate in two different "modes":
Press mode
If there are one or more press commands in the script, the plugin works in the traditional mode, which has been the only mode up to version 3.11.
Multiple (press) events can be defined; if so, the plugin will cycle through them, one (press) event for each button/dial press. When no more (press) events are defined, the plugin starts over with the first one.
(release) events are triggered when the button/dial is released. Each (release) event is matched with the (press) event immediately before it in the script. Several multi-event (release) commands can be defined following a (press) command, but only the first (release) command with all events fulfilled will be executed.
If there is a need for a (release) command where no action is needed for the preceding (press) command, you can use an empty (press) command. If you want to emphasize that no action will be performed, you can use the {noaction} action, which performs....ehh...no action. :-)
[(press)]
[(press){noaction}]
Release mode
If there are no (press) commands in the script, the plugin works only with (release) commands. The primary use for the release mode is for dials, where at the press moment, it is not clear what the purpose of the dial press is; is it pressed to be rotated or pressed just to be released?
Release mode requires the script to have absolute no (press) commands. In this mode, multiple (release) events can be defined; if so, the plugin will cycle through them, one (release) event for each button/dial release. When no more (release) events are defined, the plugin starts over with the first one.
In release mode, the {nextpress} action will not work. If you need to use the {nextpress} action, you need to use the press mode and add an empty (press) command for each (release) command.
Event property values
Event properties can be defined in different ways. Each property is documented with a set of options where the permitted options are marked with a green checkmark like this:
| ✅ | Single value | ✅ | Interval | ❌ | Transition | ✅ | * All values | ✅ | Negation | ✅ | Wildcards | ✅ | Variable reference | ✅ | Regex |
- A single value is defined by a single integer (25) or, where appropriate, a string enclosed in quotation marks ("Channel 1").
- An interval is defined if the event should trigger for multiple values; the range is defined as 25-64.
- A transition is defined when the event should trigger when the value transitions from one value to another. The transition event is using the "<>" characters. The event (_event_:<64<) will trigger when the previous value for the event was above 64, and the current value is 64 or below. The event (_event_:>64>) will trigger when the previous value for the event is below 64 and the current value is 64 or above.
- All values is defined with "*".
- A negation is defined with a preceeding ! The event (cc:1,1,24) will trigger when the received value is 24; the event (cc:1,1,!24) will trigger for all received values except 24. Negations can be combined with other options, e.g., (cc:1,1,!10-20) will trigger for all received values except those in the range 10-20.
- Wildcards allow you to use ? and * as replacements for one or multiple characters.
The event (cc:1,1,?4) will trigger for all two-digit received values ending with a 4.
The event (cc:1,1,1*) will trigger for all received values that start with 1. - Variables can be referenced by their name without surrounding hash characters. Unlike variable references in actions, events cannot process math expressions; only the plain variable name is allowed.
The event (cc:1,1,@l_MyVar) will trigger for all received values mapping to the content of the variable @l_MyVar. The variable can store the same content as the parameter allows; for example, it could be an integer to match a single value or the string "10-20" to specify a range. - A Regex value is defined as "Regex(expression)". Example: the event (cc:1,1,Regex(^[12]{2}$)), will trigger for all received two-digit values made up of only ones and twos.
Note: If you have an event capable of handling text, such as a variable event, there may be times when you want it to trigger on an exact string, even if that string contains characters that usually indicate another option, like an interval. To enforce string handling, enclose the property in quotation marks.
For example, if you want an event to trigger specifically on the string "10-20" and not interpret it as an interval:
- (@l_MyVar:10-20) will trigger if the variable @l_MyVar is set to a value between 10 and 20.
- (@l_MyVar:"10-20") will trigger if the variable @l_MyVar is set to the string value "10-20".
Note 2: When referencing a variable in an event, the variable's value is only checked when the main event occurs; changing the variable's value will not trigger the event. Example:
(cc:1,1,@l_MyVar) will only trigger when the CC command is received, not when the content of @l_MyVar changes.
Please note that many events are treated differently when used in multi-event commands. This table describes the event logic used in single-event commands; please see the Multi-event commands page for the event logic in multi-event commands.
Events
(init)
(init+)
The (init) event is triggered once when the script is loaded.
The (init+) event is likewise triggered when the script is loaded, but also whenever the additional event(s) in the command are triggered.
Example: Assume you want to display a text when a specific CC command is received and also want this text to be present when you switch to the page with the script. Using the (init) command, you would need to define two commands: one for the init phase and one for the running operation:
[(init)(cc:1,1,0){text:Super\nDuper}]
[(cc:1,1,0){text:Super\nDuper}]
If you use (init+), a single command handles both functions:
[(init+)(cc:1,1,0){text:Super\nDuper}]