A WebSocket remote
rb.net.ws_listen serves a script over WebSocket, so another program can send
it commands and receive pushed messages. This script accepts JSON commands to
type text and move the mouse, and answers each request that carries an id.
websocket-client package:
rb.net.ws_listenneeds thenetpermission. Without thehostoption it listens on every network interface, which lets other computers connect.- This script has no authentication. Any program on the computer can connect, including a web page open in a browser. Add a token check before you let it do anything you would not let every local program do.
- Incoming messages are dispatched in batches each tick; the per-tick limits are under Limits.
An HTTP trigger
rb.net.listen serves HTTP on 127.0.0.1 unless it is given a host, so a
shell script, a Stream Deck action, or a cron job on this computer can trigger
a key press with one request. The handler answers at once and hands the press to
rb.run, because a handler cannot wait.
pcall. The server has no authentication, so any program on the
computer can trigger it. See rb.net.listen
for the request and response fields.
A screen-condition trigger
rb.screen.pixel_hex reads one pixel. Polled on a timer, it turns a visual
state into a trigger: this script watches a status indicator and presses F5
once when it turns red, then waits for it to clear. On macOS, pixel reads need
Screen capture turned on (see Platforms).
rb.screen.search_color
instead of reading one point. When it is an icon rather than a flat color, save
a PNG of it next to the script and search for it with
rb.screen.find_image, which
always waits, so it runs inside rb.run.
Region limits, coordinates, and the options of each call are in the
screen reference. To find something you can
describe but cannot capture as a color or an image, see
AI recipes.
A timer-driven task
rb.timer.every runs a callback on an interval without blocking input. This
script nudges the cursor one pixel and back every few minutes while it is
switched on, for a long unattended job on a computer that would otherwise go
idle.
rb.run to pause between the two
moves. Timers end when the script stops.
A sidecar over shared memory
Keep perception and decisions in your own process, with your own model and stack, and hand each decision to Rebind overrb.pipe, a shared-memory channel
for a process on the same computer. rb.pipe is Windows only; elsewhere, use
the WebSocket recipe
above. Opening a pipe needs the exec permission; see
Permissions.
rb.pipe wire protocol. In Python: