Skip to main content
These recipes expose a Rebind script to other programs: a WebSocket remote, a screen-condition watcher, a timer-driven task, and a shared-memory sidecar bridge. Their transport and queue behavior is documented in Remote control.

A WebSocket remote

Net.WSListen exposes a script over a persistent connection. Use it when you need push events (server to client) or a low-latency channel for high-frequency commands. The server handles multiple clients and broadcasts to all of them. It dispatches up to 32 queued events per tick; excess messages wait for later ticks.
Connect from Python with websocket-client:
Net.WSListen can expose arbitrary JSON-RPC surfaces: reads (screen pixels, window state, clipboard, input state), writes (HID commands), and push subscriptions (mouse position, window changes, input events) compose with the same handler. For the official client libraries, see Remote control.

A screen-condition trigger

Screen.GetPixelColor samples a pixel; Screen.SearchForColor scans a region. Polling them on a tick gives you a desktop-automation trigger: act when a known visual state appears. This recipe watches a fixed point on screen and fires a keystroke when a build indicator turns red. This is the kind of thing you’d wire into a CI dashboard, a long-running render, or an accessibility cue. Screen and Window are limited or absent on Linux; see Platforms & limits.
Use Screen.SearchForColor instead of a fixed point when the indicator can move. A region up to 200k physical pixels, about 220x220 on a 2x display, scans inside one tick; scan the area the indicator can actually reach, not the quadrant:
A larger region yields on a worker thread, so call it from Run():
When the indicator is an icon rather than a flat color, search for a PNG of it with Screen.FindImage. It captures the display live, so poll it from a coroutine, where it yields instead of blocking the tick:

A timer-driven task

Timer.Every runs a callback on a fixed interval without blocking the input loop. This recipe nudges the cursor a few pixels every few minutes to keep a workstation from idling during a long unattended job, with a hotkey to toggle it.

A sidecar over shared-memory IPC

Keep the perception and decision loop in your own process, with your model and your stack. When the sidecar decides what to do, it hands the decision to Rebind over Pipe (shared-memory IPC, Windows-only) and the script emits the movement: through the OS input APIs in software mode, or as USB HID reports with a Rebind Link. The sidecar never emits input; the script does. Pipe is the low-latency path for a co-located process. For anything on the network or off-Windows, use the WebSocket recipe above.
The external process maps the same shared-memory region; the channel layout and framing are specified in the Pipe wire protocol. In Python: