Skip to content

Action JSON

Lunchpad.run() in a script takes an action as a JSON object. This page is that object, for every action a script can run.

Lunchpad.run({ type: "playSound", file: "C:\\Sounds\\airhorn.wav", volume: 0.8 });

The type says which action it is; the rest are its fields.

  • A field marked * is required. An action missing one is skipped, and the reason goes to the log.
  • Every other field may be left out: the engine fills in its default.
  • Placeholders work in text fields, exactly as they do in the editor: {{velocity}}, {{secret.key}}, and the rest. See Variables and placeholders.
  • The example under each action is the smallest object that runs.

Media

Play sound playSound

Play an audio file on an output device (`None` = app default device).

{ "type": "playSound", "file": "…" }
FieldValueWhat it is
file*text
volumenumber1.0 = 100 %; legacy allowed up to 20.0
startnumberTrim start, 0.0..1.0 of the file
endnumberTrim end, 0.0..1.0 of the file
outputDevicetext or null
volumeFromVelocitytrue or falseScale the volume by the trigger velocity (velocity-sensitive pads)

Text to speech textToSpeech

{ "type": "textToSpeech", "text": "…" }
FieldValueWhat it is
text*text
voicetext or null
volumenumber

System audio setSystemVolume

Volume or mute of the default output or input device. `volume` is the level (0-100 %) for `Set`, the step for `Adjust`, unused for the mutes.

{ "type": "setSystemVolume", "target": "output", "volume": 0 }
FieldValueWhat it is
target*SystemVolumeTarget
modeSystemVolumeMode
volume*number
volumeFromtext or nullVariable or placeholder that overrides `volume` when it holds a number
devicetext or nullA specific device by name; `None` = the system's default device

Switch audio device setAudioDevice

Make a device the system default output (speakers) or input (microphone).

{ "type": "setAudioDevice", "target": "output", "device": "…" }
FieldValueWhat it is
target*SystemVolumeTarget
device*textDevice name as the system lists it (placeholders allowed)

Stop all sounds stopAllSounds

Stop every sound Lunchpad is playing.

{ "type": "stopAllSounds" }

General

Delay delay

{ "type": "delay", "ms": 0 }
FieldValueWhat it is
ms*number
msFromtext or nullA variable (or `{{template}}`) holding the milliseconds; `ms` when it is missing or not a number.

Switch page switchPage

{ "type": "switchPage", "pageId": "…" }
FieldValueWhat it is
pageId*text

Run another button runButton

Run another button's actions as part of this chain. With `wait` the runner waits for the other button's macro to finish.

{ "type": "runButton", "target": { "x": 0, "y": 0 } }
FieldValueWhat it is
target*ButtonRef
triggerButtonTrigger

Set colour setColor

Change and persist the colour of a button: this one (no target) or any other button on any page.

{ "type": "setColor", "color": { "mode": "palette", "index": 0 } }
FieldValueWhat it is
color*PadColor
targetButtonRef or null

Set fader setFader

Move a fader (by name) to a value, as if its pad had been pressed: LEDs, `fader.<name>` and, unless `run_actions` is off, its actions.

{ "type": "setFader", "fader": "…", "value": "…" }
FieldValueWhat it is
fader*text
value*textNumber or placeholder, clamped to the fader's range
runActionstrue or false

Flow

Condition ifStart

Branch: actions up to `IfElse` run when the condition holds, actions between `IfElse` and `IfEnd` when it does not.

{ "type": "ifStart", "variable": "…", "op": "equals", "elseId": "…", "endId": "…" }
FieldValueWhat it is
variable*text
op*CompareOp
valuetext
elseId*text
endId*text

Loop loopStart

Loop: the actions up to `LoopTimeout` repeat, with a pause between rounds. `Count` runs the body once per value from `from` to `to` in steps of `step` (`loop.value`); `Until` repeats until the check holds, checked before or after each round; `Forever` repeats until the macro is stopped. When `timeout_ms` has passed, the actions between `LoopTimeout` and `LoopEnd` run instead. Everything after the end runs either way.

{ "type": "loopStart", "timeoutId": "…", "endId": "…" }
FieldValueWhat it is
modeLoopMode
variabletext
opCompareOp
valuetext
checkLoopCheck`Until` only: where the check runs.
fromtext`Count` only: first value, last value and step; placeholders allowed.
totext
steptext
intervalMsnumberPause between two rounds, in milliseconds (never below `LOOP_MIN_INTERVAL_MS`).
timeoutMsnumberTime limit counted from the first round; 0 = none.
timeoutId*text
endId*text

Flip flop: A flipFlopStart

Actions between Start and Middle run on "A" presses, between Middle and End on "B" presses; `is_a` alternates and is persisted.

{ "type": "flipFlopStart", "middleId": "…", "endId": "…" }
FieldValueWhat it is
middleId*text
endId*text
isAtrue or false

Push-to-talk on pushToTalkStart

{ "type": "pushToTalkStart", "endId": "…" }
FieldValueWhat it is
endId*text

System

Launch application launchApplication

{ "type": "launchApplication", "executable": "…" }
FieldValueWhat it is
executable*text
argumentstext
hiddentrue or false
killOnStoptrue or false
saveOutputTotext or nullStore the program's standard output in this variable (needs `wait`)
saveScopeVarScope

HTTP request httpRequest

Any HTTP call. URL, headers, body and auth may contain `{{velocity}}`, `{{x}}`, `{{y}}` and `{{pageId}}`.

{ "type": "httpRequest", "method": "get", "url": "…" }
FieldValueWhat it is
method*HttpMethod
url*text
headerslist of HttpHeader
contentTypetext or nullContent-Type for the body (`None` sends none / lets the mode decide)
bodytextText body, or `name=value` lines for a multipart form
bodyModeHttpBodyMode
bodyFiletext or nullFile whose bytes are sent as the body (`body_mode = File`)
fileslist of HttpFilePartFile parts of a multipart form (`body_mode = Multipart`)
authHttpAuth
timeoutMsnumber
ignoreTlsErrorstrue or false
saveTotext or nullStore the response body in this variable (`<name>.status` gets the status code, `<name>.file` the saved file, `<name>.cached` whether the file was reused)
saveScopeVarScope
responseHttpResponseWhat becomes of the response: text only, or a file in the download folder made from the body, a base64 field or a URL in a field
responseFieldtextJSON field (dot path, `data.0.url`) for the field modes; empty = the whole body
fileNametextFile name (placeholders allowed) in the download folder, or an absolute path; empty = a name derived from the request
reusetrue or falseSkip the request when a file (or stored text) for the same inputs exists

Run script runScript

Run a JavaScript snippet with access to the variables; its result can be stored in a variable.

{ "type": "runScript", "code": "…" }
FieldValueWhat it is
code*text
saveTotext or null
saveScopeVarScope

Set variable setVariable

Set a variable to a value (placeholders allowed).

{ "type": "setVariable", "name": "…", "value": "…" }
FieldValueWhat it is
name*text
value*text
scopeVarScope

Add to variable addToVariable

Add a number to a variable (counters); missing or non-numeric values count as 0.

{ "type": "addToVariable", "name": "…", "amount": "…" }
FieldValueWhat it is
name*text
amount*textNumber or placeholder, negative to subtract
scopeVarScope

Debug window debug

Show a window with `text`, placeholders filled in. Each action has its own window; running it again updates the text.

{ "type": "debug" }
FieldValueWhat it is
titletext
texttext
alwaysOnToptrue or falseKeep the window above the others

Keyboard & mouse

Hotkey sequence hotkey

{ "type": "hotkey", "keystrokes": [ { "type": "key", "event": "down", "key": "…", "modifiers": [ "…" ] } ] }
FieldValueWhat it is
keystrokes*list of Keystroke
restoreAllAtEndtrue or false

Mouse sequence mouse

Mouse steps run in order: move, click, press, release, scroll, drag, wait.

{ "type": "mouse" }
FieldValueWhat it is
stepslist of MouseStep

Get mouse position mousePosition

Remember where the pointer is: `<name>` = "x,y", plus `.x` and `.y`.

{ "type": "mousePosition", "saveTo": "…" }
FieldValueWhat it is
saveTo*text
saveScopeVarScope

Window

Get window getWindow

Find another program's window, the one in front or by title, and remember it: `<name>` = its handle, plus `.title`, `.app`, `.x`, `.y`, `.width` and `.height`.

{ "type": "getWindow", "saveTo": "…" }
FieldValueWhat it is
targetWindowTarget
titletext
matchingTitleMatch
apptext
saveTo*text
saveScopeVarScope

Set window setWindow

Find another program's window and raise, minimize, maximize, restore, lower, close, move, size or center it.

{ "type": "setWindow" }
FieldValueWhat it is
targetWindowTarget
titletext
matchingTitleMatch
apptext
opWindowOp
xtext
ytext
widthtext
heighttext
screentext1-based screen number, blank for the window's own; `move`, `bounds` and `center` take it as their frame of reference, `screen` moves there.

Get screen getScreen

Remember a screen: `<name>` = JSON with number, x, y, width, height, scale, dpi, primary and count (of screens), each also as `<name>.<field>`.

{ "type": "getScreen", "saveTo": "…" }
FieldValueWhat it is
pickScreenPick
numbertextThe 1-based number, for `pick: number` (placeholders)
saveTo*text
saveScopeVarScope

Stop

Stop this macro stopThisMacro

{ "type": "stopThisMacro" }

Restart this macro restartThisMacro

{ "type": "restartThisMacro" }

Stop all macros stopAllMacros

{ "type": "stopAllMacros" }

OBS Studio

OBS: switch scene obsSwitchScene

{ "type": "obsSwitchScene", "scene": "…" }
FieldValueWhat it is
scene*text
collectiontext

OBS: show or hide source obsToggleSource

{ "type": "obsToggleSource", "scene": "…", "source": "…", "visible": true }
FieldValueWhat it is
scene*text
collectiontext
source*text
visible*true or false
modeVisibilityMode or nullShow / hide / toggle; `None` falls back to `visible`

OBS: set audio obsSetAudio

{ "type": "obsSetAudio", "scene": "…", "source": "…", "muted": true, "volumeDb": 0 }
FieldValueWhat it is
scene*text
collectiontext
source*text
muted*true or false
muteModeMuteMode or nullMute / unmute / toggle / keep; `None` falls back to `muted`
volumeDb*numberVolume in `volume_unit` (dB: -100..26, percent: 0..2000 like OBS's advanced audio properties)
volumeFromtext or nullVariable or placeholder that overrides `volume_db` when it holds a number (faders write `value`)
volumeUnitVolumeUnit
setVolumetrue or falseWhether the volume is applied at all (a pure mute button leaves it alone)

OBS: toggle filter obsToggleFilter

{ "type": "obsToggleFilter", "source": "…", "filter": "…", "enabled": true }
FieldValueWhat it is
source*text
filter*text
enabled*true or false

OBS: stream, record, replay obsStream

{ "type": "obsStream", "target": "stream", "mode": "start" }
FieldValueWhat it is
target*ObsTarget
mode*ObsMode

OBS: save replay obsSaveReplay

{ "type": "obsSaveReplay" }

OBS: studio mode obsStudioMode

Studio mode on/off, or push the preview scene to the program.

{ "type": "obsStudioMode", "mode": "enable" }
FieldValueWhat it is
mode*StudioMode

OBS: trigger hotkey obsTriggerHotkey

Fire an OBS hotkey over the websocket, without giving OBS the focus: by its name (`OBSBasic.StartStreaming`; `context` names the source for per-source ones such as `libobs.mute`) or by the key combination bound in OBS (`key` is an OBS key id such as `OBS_KEY_F5`).

{ "type": "obsTriggerHotkey" }
FieldValueWhat it is
byObsHotkeyBy
nametext
contexttext
keytext
shifttrue or false
controltrue or false
alttrue or false
commandtrue or false

Streamlabs

Streamlabs: switch scene slobsSwitchScene

Streamlabs Desktop: the same controls as OBS, by name.

{ "type": "slobsSwitchScene", "scene": "…" }
FieldValueWhat it is
scene*text
collectiontext

Streamlabs: show or hide source slobsToggleSource

{ "type": "slobsToggleSource", "scene": "…", "source": "…", "visible": true }
FieldValueWhat it is
scene*text
collectiontext
source*text
visible*true or false
modeVisibilityMode or null

Streamlabs: set audio slobsSetAudio

{ "type": "slobsSetAudio", "scene": "…", "source": "…", "muted": true, "volumeDb": 0 }
FieldValueWhat it is
scene*text
collectiontext
source*text
muted*true or false
muteModeMuteMode or null
volumeDb*numberVolume in `volume_unit`: dB mapped onto the mixer fader, or percent as the fader position
volumeFromtext or null
volumeUnitVolumeUnit
setVolumetrue or false

Streamlabs: toggle filter slobsToggleFilter

{ "type": "slobsToggleFilter", "source": "…", "filter": "…", "enabled": true }
FieldValueWhat it is
source*text
filter*text
enabled*true or false

Streamlabs: stream, record, replay slobsStream

{ "type": "slobsStream", "target": "stream", "mode": "start" }
FieldValueWhat it is
target*ObsTarget
mode*ObsMode

Streamlabs: save replay slobsSaveReplay

{ "type": "slobsSaveReplay" }

Streamlabs: studio mode slobsStudioMode

Studio mode on/off, or push the preview live.

{ "type": "slobsStudioMode", "mode": "enable" }
FieldValueWhat it is
mode*StudioMode

Home Assistant

Home Assistant: on / off homeAssistantTurn

Home Assistant: turn an entity on or off (or toggle it)

{ "type": "homeAssistantTurn", "entity": "…" }
FieldValueWhat it is
entity*text
modeHaPower

Home Assistant: set a value homeAssistantSetValue

Home Assistant: set a numeric property, fixed or from a variable / fader

{ "type": "homeAssistantSetValue", "entity": "…", "value": 0 }
FieldValueWhat it is
entity*text
kindHaValueKind
value*number
valueFromtext or nullVariable or placeholder that overrides `value` when it holds a number

Home Assistant: call a service homeAssistantCallService

Home Assistant: call any service; `data` is JSON and may contain placeholders

{ "type": "homeAssistantCallService", "domain": "…", "service": "…" }
FieldValueWhat it is
domain*text
service*text
entitytext
datatext

The types they use

ButtonRef

Reference to a button; `page_id: None` means the page of the calling button.

FieldValueWhat it is
pageIdtext or null
x*number
y*number

ButtonTrigger

Which list of another button to run.

ValueWhat it means
"press"*The `down` actions
"release"The `up` actions
"tap"`down` then `up`
"hold"The long-press (`hold`) actions

CompareOp

ValueWhat it means
"equals"*
"notEquals"
"contains"
"startsWith"
"endsWith"
"greaterThan"
"lessThan"
"isEmpty"
"isNotEmpty"
"matches"Regular expression match

HaPower

On / off / toggle through the `homeassistant` domain, which works for every entity kind.

ValueWhat it means
"on"*
"off"
"toggle"

HaValueKind

Numeric things an entity can be set to.

ValueWhat it means
"brightness"*Light brightness, 0–100 %
"colorTemperature"Light colour temperature in Kelvin
"position"Cover position, 0 (closed) – 100 (open)
"fanSpeed"Fan speed, 0–100 %
"volume"Media player volume, 0–100 %
"number"`number` / `input_number` value, in the entity's own unit
"temperature"Climate target temperature

HttpAuth

An object whose type says which one it is:

typeWithWhat it means
"none"*nothing else
"basic"usernamepassword
"bearer"token

HttpBodyMode

ValueWhat it means
"text"*`body` text with `content_type`
"file"The bytes of `body_file`
"multipart"multipart/form-data: `body` lines as text fields, `files` as file parts

HttpFilePart

FieldValueWhat it is
field*textForm field name, e.g. "file"
path*text
filenametext or nullFilename sent to the server; defaults to the file's own name
contentTypetext or nullContent type of the part; guessed from the extension when empty

HttpHeader

FieldValueWhat it is
name*text
value*text

HttpMethod

ValueWhat it means
"get"
"post"
"put"
"patch"
"delete"
"head"

HttpResponse

What an HTTP action does with the response body.

ValueWhat it means
"text"*Keep the text in the variable only
"file"The body is the file
"base64Field"A field holds base64 data (a data URL prefix is fine)
"urlField"A field holds a URL to download

KeyEvent

ValueWhat it means
"down"
"up"
"tap"

Keystroke

An object whose type says which one it is:

typeWithWhat it means
"key"eventkeymodifiers
"delay"ms
"text"textdelayMs

LoopCheck

Where an `Until` loop checks: before a round (the body may never run) or after it (the body runs at least once).

ValueWhat it means
"head"*
"tail"

LoopMode

What makes a loop go round.

ValueWhat it means
"count"From a first to a last value, in steps: a counted loop.
"until"*Until the check holds.
"forever"Until the macro is stopped (or the time limit hits).

MouseButton

A mouse button as the actions name it.

ValueWhat it means
"left"*
"right"
"middle"

MouseStep

One step of a mouse sequence. Coordinates and amounts are strings so they take placeholders.

An object whose type says which one it is:

typeWithWhat it means
"move"xyrelativePut the pointer at `x`, `y`, or with `relative` move it by that much
"click"buttonclicksClick `clicks` times (1–5) where the pointer is
"press"buttonHold a button down until a release step
"release"button
"scroll"amountaxisTurn the wheel by `amount` notches: positive down (or right)
"drag"xybuttonPress a button where the pointer is, move to `x`, `y`, let go
"delay"msWait `ms` milliseconds (at most 5000)

MuteMode

ValueWhat it means
"mute"
"unmute"
"toggle"
"keep"Leave the mute state alone

ObsHotkeyBy

How an OBS hotkey is picked.

ValueWhat it means
"name"*By the hotkey's name in OBS
"keys"By the key combination bound in OBS

ObsMode

ValueWhat it means
"start"
"stop"
"toggle"

ObsTarget

ValueWhat it means
"stream"
"record"
"replay"

PadColor

What a pad's LED shows. Palette indices refer to Novation's 128 colours.

An object whose mode says which one it is:

modeWithWhat it means
"palette"index
"flashing"indexalt
"pulsing"index
"rgb"rgb

ScreenPick

Which screen a get-screen action means.

ValueWhat it means
"primary"*The main display
"number"By its number
"foreground"The one the foreground window is on
"pointer"The one under the pointer

ScrollAxis

ValueWhat it means
"vertical"*
"horizontal"

StudioMode

ValueWhat it means
"enable"
"disable"
"toggle"
"transition"Make the preview scene live (studio mode must be on)

SystemVolumeMode

ValueWhat it means
"set"*Set the level
"adjust"Change the level by the amount (negative = quieter)
"mute"
"unmute"
"toggleMute"

SystemVolumeTarget

ValueWhat it means
"output"Speakers / headphones
"input"Microphone

TitleMatch

How a title is compared.

ValueWhat it means
"contains"*
"startsWith"
"exact"
"regex"

VarScope

Where a variable lives: `Local` registers belong to one macro run (and the buttons it calls), `Global` variables are shared by every macro.

ValueWhat it means
"local"*
"global"

VisibilityMode

ValueWhat it means
"show"
"hide"
"toggle"

VolumeUnit

How a volume number is meant: decibels, or percent of the app's own scale.

ValueWhat it means
"db"*
"percent"

WindowOp

ValueWhat it means
"focus"*
"minimize"
"maximize"
"restore"
"sendToBack"
"close"
"move"To `x`, `y`, on `screen` when given (a blank coordinate keeps the window's place)
"resize"To `width` × `height`
"bounds"Move and resize at once
"center"On `screen`, or on the window's own screen
"screen"To `screen`, keeping the window's place on it

WindowTarget

Which window a window action means.

ValueWhat it means
"foreground"The window with the focus right now
"title"*By title (and program)