RemoteControl

class RemoteControl : Extension(source)

Exposes a program over a local HTTP server: a screenshot of the current frame can be requested, and keyboard/mouse events can be injected as if a real user produced them -- intended for driving an OPENRNDR program from an external tool (a test suite, an agent) that can't attach to the window directly.

All routes are served on network:port (default 127.0.0.1:9000, i.e. not reachable from outside the machine by default -- change network deliberately if that's not what you want).

Routes

  • GET /screenshot -- waits for the next frame and returns it as a PNG.

  • POST /keyboard/down?name=<key>, POST /keyboard/up?name=<key>, POST /keyboard/repeat?name=<key> -- inject a key event. name is the layout-sensitive key name as used by org.openrndr.KeyEvent.name (e.g. a, spacebar, arrow-left). An optional modifiers query parameter takes a comma-separated list of SHIFT, CTRL, ALT, SUPER.

  • POST /mouse/move?x=<x>&y=<y> -- move the mouse to an absolute window position.

  • POST /mouse/button/down?x=<x>&y=<y>&button=<LEFT|RIGHT|CENTER>, POST /mouse/button/up?... -- press/release a mouse button, optionally moving to x/y first (omit x/y to use the current position).

  • POST /mouse/scroll?dx=<dx>&dy=<dy> -- inject a scroll event.

  • POST /clock?time=<seconds> -- freeze Program.seconds at a fixed value, e.g. for deterministic, reproducible screenshots of an animation at a specific point in time. POST /clock/reset restores the real (or otherwise previously active) clock.

All events are delivered through the same (thread-safe, postponed) event queue real input uses, applied on the program's own thread right before the next frame is drawn -- so this is safe to call from any thread, including ktor's own request-handling threads.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
open override var enabled: Boolean
Link copied to clipboard

the network interface to bind to; the default only accepts connections from localhost

Link copied to clipboard
var port: Int
Link copied to clipboard

true while Program.clock is overridden to a fixed value requested through POST /clock; reading this reflects the extension's current state, setting it has no effect (use the /clock and /clock/reset routes instead).

Functions

Link copied to clipboard
open override fun afterDraw(drawer: Drawer, program: Program)
Link copied to clipboard
open override fun beforeDraw(drawer: Drawer, program: Program)
Link copied to clipboard
open override fun setup(program: Program)
Link copied to clipboard
open override fun shutdown(program: Program)