pixelactions-core
The platform-free core of
pixelactions: coordinate-space
conversion, the flow-file schema, label resolution, the line protocol's
wire types, and the run-report format — with no input synthesis, no OS
calls, and #![forbid(unsafe_code)].
Want the tool? Install the binary: cargo install pixelactions.
Want to build your own executor, client, or planner? That's this
crate.
[]
= "0.6"
What you'd use it for
pixelcoords answers where is this thing. pixelactions answers act on it, then confirm it landed. This crate is the half of that with no platform in it — which turns out to be the half that is easy to get wrong.
Build on it when you want to:
- convert a saved coordinate into whatever your input API expects — the single most valuable thing here, and the thing most tools get wrong
- write your own executor over a different input backend (a VM, a remote desktop, a robot arm) while keeping the same flow files
- write a Rust client for the
serveline protocol, or an alternative server that speaks it - parse and validate flow files or chained-argv verbs in your own tooling
The binary is deliberately thin on top of this. Everything it decides about where to act lives here, where it can be unit-tested without a screen.
Coordinate spaces: the reason this crate exists
A pixelcoords session records physical pixels. Input APIs disagree about what they want:
| Platform | Input API | Speaks |
|---|---|---|
| macOS | CGEvent |
logical points, global space, origin top-left |
| Windows | SendInput |
physical pixels, normalized across the virtual desktop |
| Linux / X11 | XTEST |
physical pixels on the root window |
The same saved coordinate therefore needs a different conversion per
platform, and getting it wrong does not error — it clicks the wrong
place. Space::Auto resolves to whatever the current platform needs,
decided in exactly one place (native_space()), so no call site guesses.
use ;
use ;
use MonitorRecord;
let monitors = vec!;
// Physical (850, 440) on the Retina display is logical (425, 220).
let point = to_space.expect;
assert_eq!;
assert_eq!;
// The same physical coordinate on the 1x panel is unchanged, because
// conversion divides by the *containing* monitor's scale — never a
// global one. Mixed-DPI desktops are the normal case, not an edge case.
let external = to_space.expect;
assert_eq!;
assert_eq!;
// A point in the gap between monitors is refused, never clamped —
// clamping would click somewhere plausible and wrong.
assert!;
// What `Auto` means here, decided once:
assert!;
monitor_at answers containment on its own, and corners /
near_screen_corner back the kill switch — a cursor found in a screen
corner stops a run, because grabbing the mouse is what a person does
when automation goes wrong.
Flow files
A flow references regions by label, never by raw coordinate. That indirection is the point: a label survives the UI moving, and a diff shows intent ("click submit") rather than arithmetic.
use ;
#
Parsing is strict: unknown keys are errors, not silent no-ops, so a typo fails at parse time instead of skipping a step at run time. (Session parsing, by contrast, is deliberately tolerant — unknown fields from a newer pixelcoords are ignored, so the two tools release independently.)
Resolving labels to points
plan turns a flow plus a session into concrete coordinates, or refuses.
It is total: every label resolves before any action runs, because a
half-executed flow is the worst outcome this tool can produce.
use Space;
use Flow;
use ;
use SessionFile;
#
#
# const EXAMPLE_SESSION: &str = r#"{
# "schema": 1,
# "app": { "name": "pixelcoords", "version": "0.2.1" },
# "created_utc": "2026-07-29T00:00:00Z",
# "monitors": [
# { "index": 0, "name": "Built-in", "primary": true,
# "origin_px": { "x": 0, "y": 0 },
# "size_px": { "w": 3600, "h": 2338 }, "scale": 2.0 }
# ],
# "selections": [
# { "shape": "rect", "label": "submit", "monitor": 0,
# "px": { "x": 800, "y": 400, "w": 100, "h": 80 },
# "global_px": { "x": 800, "y": 400, "w": 100, "h": 80 },
# "crop": "submit.png" }
# ]
# }"#;
The same verbs, three ways
Chained argv, flow files, and the line protocol all build the same
Step, so learning one teaches the others and none can drift.
use Step;
use ;
use parse_all;
#
Parsing a chain is all-or-nothing by design: a typo in step 7 must not perform steps 1 through 6 first.
Speaking the line protocol
protocol holds both directions of the wire format, so you can write a
Rust client for pixelactions serve — or an entirely different server
that speaks the same thing.
use ;
let welcome = Response ;
// One JSON object per line, newline included — no embedded newlines, in
// either direction.
let line = welcome.to_line;
assert!;
assert_eq!;
assert!;
The framing rules are the ones LSP, esbuild, and MCP all converged on: one JSON object per line; stdout carries protocol only and stderr is logs; closing stdin is the graceful shutdown; and a version handshake first, so the protocol can change later without breaking programs written against it today.
Reporting what happened
report carries the vocabulary the whole tool reports in — and the
distinctions are the point.
use ;
// "The OS accepted the event" is not "the app reacted to it".
assert_eq!;
assert_eq!;
// And "it did not work" is not "I declined to try": a refusal is never
// worth retrying, so it earns its own exit code.
let refused = RunReport ;
assert_eq!;
Exit codes are the API: 0 done · 1 a step failed honestly · 2 malformed question · 3 refused.
The modules
| Module | What it is |
|---|---|
convert |
coordinate spaces, per-monitor scaling, screen corners |
flow |
the flow-file schema and its steps, parsed strictly |
plan |
resolving labels against a session, totally or not at all |
verb |
the chained-argv verb:argument grammar |
protocol |
the serve line protocol, both directions |
report |
run reports, step outcomes, the exit-code contract |
chord |
reading cmd+shift+s into modifiers and a key |
Relationship to pixelcoords-core
This crate depends on pixelcoords-core for the session schema, and the dependency is one-way and forever — the two tools release independently and neither is pinned to the other's schedule. Sessions are read through pixelcoords' own types, which ignore unknown fields, so every additive schema change upstream is a no-op here. Our own config is parsed strictly: tolerance is for other people's data, not ours.
Stability, honestly. This is pre-1.0 and shares a version with the
binary, so a minor bump can change any signature. The flow file, the
line protocol, and the exit codes are the parts with a real
compatibility promise — the protocol carries PROTOCOL_VERSION and a
handshake precisely so it can change without breaking your program. Pin
a caret range and read the
CHANGELOG
before upgrading.
Every example above is compiled and run as a doctest in CI, so nothing on this page can rot silently.
See also
- pixelcoords — the other half: mark regions, get pixel-exact coordinates
- docs/FLOW.md — every step and setting
- docs/PROTOCOL.md — the line protocol, with a working client
- API docs · repository · pixelactions.dev
MIT licensed.