Messages
Every message is one JSON object in a WebSocket text frame; binary frames are not accepted. A request names its command int. Include an id to get a
reply; leave it out to send without waiting.
id gets an error reply:
id gets no reply; the server only writes the
error to its log. So does a frame that is not a JSON object. Send an id
whenever you need to know a command worked.
The hello banner
On connect, the server sends a banner with the protocol version, the host platform, whether a token is required, and which gates are on:platform is "windows" or "macos". Send hello yourself to get the
banner again as a reply:
Error codes
Authentication
A token is optional. When Auth token is set in Options, a client must send{ "t": "auth", "token": "..." } first. Until it does, every command except
hello, ping, and auth is refused with unauthenticated. With no token
set, auth replies { "ok": true, "note": "no token required" }, and any
program on this computer, including a web page open in a browser, can send
every command that is not gated. The server asks no one before
accepting a connection.
ui.get and ui.get_all never return the token.
While Local only is on (the default), the server listens on 127.0.0.1.
Turned off, it listens on every network interface; see the warning in
Run the server.
Gates
Five groups of commands are off until their toggle in Options is on. A gated command returnsdisabled while its toggle is off. No command changes a
toggle directly; lua.exec, once its gate is on, can.
exec, file, registry and lua each give a client full control of the
computer; see Options.
Commands
Send{ "t": "commands", "id": 1 } to get the exact list a server exposes:
{ "commands": [...], "protocol": "2.5.0" }. The tables give each command’s
request fields and its reply. A reply of ok is { "ok": true }. Optional
fields are marked ?. A reply field with no value is left out, not sent as
null.
Many commands depend on the platform. A command the operating system does not
support replies handler_error with the reason; the registry.* commands, for
example, work only on Windows. Support per OS follows
Platforms.
Commands marked async wait for their work to finish before replying, while
the server keeps handling other messages. Always send an id with them.
HID
Key names are in the key reference.
The joypad commands work like
rb.hid.joypad
and rb.hid.axis. They need a Rebind Link whose USB profile has a joypad;
elsewhere they reply handler_error with the reason, and so does a value out
of range. As with every command, an error comes back only when the request has
an id. Leave a field out rather than sending null, which is refused. The
joypad state is shared with every script and stays after the connection
closes, until hid.joypad_reset, or until Remote Control or any other script
stops or errors; hid.joypad_reset also drops what other scripts set.
hid.down, hid.up, hid.press, and hid.combo also press controller
buttons such as PadA.
Screen
screen.capture returns the image as a base64 PNG with the captured display’s
geometry and the cursor position, so a client can map image pixels back to
screen coordinates. display is a 1-based index from screen.displays; when
it is left out, the server captures the display under the cursor. region is
{ x, y, w, h } in that display’s coordinates; when it is left out, the whole
display is captured. max_edge defaults to 1280: the frame is scaled down so
its longer edge fits, which keeps a 4K capture small. Pass 0 for full
resolution. screen.capture_window finds the window by handle or title and
captures its rectangle, clipped to the display it sits on.
System and input
Windows, apps, and processes
Data and text
Files
Everyfile.* command is behind the file gate. Paths are relative to the
Remote Control package’s folder; absolute paths, paths containing .., and
paths that leave the folder are refused. Paths starting with @data/ reach
the package’s
data folder instead.
Network, macros, audio, and timers
In every
net.* reply, a response body that is not UTF-8 arrives as
body_base64 instead of body.
A timer pushes { "t": "timer", "handle": 3, "kind": "after" } (or "every")
to the connection that created it each time it fires. A connection’s timers
are cancelled when it closes.
Registry, log, UI, and script
ui.* reads the Remote Control script’s own Options and cannot change them.
script.exit stops the server.
Observation
Theobserve.* commands record what the person at the computer does, through
rb.observe, and read recordings back.
They are behind the observe gate. A recording holds every key you press,
passwords included, and screenshots of the screen. On Rebind 3.23.0 and later
it also holds what Rebind itself sends, the commands of this protocol
included, and the names of the controls in the front window. What else it holds, its
folder, and the lines observe.events returns are described under
observe. A recording’s id travels in session,
since id is the request’s correlation id.
A status has the fields of the line
rebind observe prints
(observe) other than state and file, plus
owner_kind, and stop_key when a key ends it (Rebind 3.21.0 and later).
The banner carries no Rebind version: a status with an outputs count comes
from Rebind 3.23.0 or later, whose recordings log what Rebind sends. A
recording in recordings has id, name, goal, owner, owner_kind,
started_at, ended_at, seconds, the same counts plus dropped_marks,
frames_off, reason, and running while it records.
One recording runs at a time, whoever started it: the app, the CLI, a script,
or Remote Control. observe.start while one runs replies handler_error with
rb.observe.start: An observation is already running. A recording Remote
Control starts has owner_kind script and the Remote Control script’s name
as owner.
Only the connection that started a recording can mark or stop it; others get
not_owner, and so do they while a connection’s observe.start is still
waiting for the recorder. The recording stops when that connection closes, and
ends with the reason script_stopped when Remote Control stops. observe.stop
right after a recording ended on its own, at its time limit or stop key,
replies with that recording’s final status. With no recording of Remote
Control’s to stop, it replies handler_error with
rb.observe.stop: this script has no observation running.
observe.list, observe.events, observe.frame and observe.read read every recording,
including the app’s and the CLI’s. No command renames or deletes one; to
delete one, remove its folder from the observations folder. observe.events or observe.frame without a session
replies handler_error with observe.events: session must be a string (or
observe.frame:, observe.read:). An unknown session, a file that is not an observation
image name (as a frame or crop line gives it), a missing file, or an image
over 2 MB as base64 also replies
handler_error; ask for a smaller max_edge for a large image.
Meta
lua.exec runs the chunk once inside the server script, with that script’s
permissions. End the chunk with return <value> to get a result.
Event streams
Aftersubscribe, the server pushes frames on every script tick:
The package ticks 1,000 times a second, so an
input subscription receives up
to 1,000 frames a second. Subscriptions end when the connection closes.