pixelactions-core
A coordinate is only worth having if something acts on it. pixelactions is the second half of that loop: it reads a session a human marked in pixelcoords, resolves the label to a point, performs the interaction, and confirms it landed.
This is its platform-free core: coordinate conversion, flow files, the
planner, the line protocol, the step vocabulary, and the run report — with
no input backend, no OS calls, and #![forbid(unsafe_code)].
Want the tool? cargo install pixelactions.
Want to build on it? This crate — it is what you use to generate
flows, parse reports, or drive the protocol from Rust.
[]
= "0.9"
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.
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.7.7" },
# "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" }
# ]
# }"#;
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.)
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.
Modules
| Module | What it owns |
|---|---|
flow |
the flow file: steps, settings, parsing — strict, unknown keys refused |
verb |
the chained-argv grammar (click:submit, scroll:list>3) |
plan |
resolving labels to points, and refusing when it cannot |
convert |
physical ↔ logical, and which one this platform's input API wants |
protocol |
the line protocol: requests, responses, the advertised verbs |
report |
the run report — what executed, what verified, what failed |
audit |
the append-only record of what a run did |
Full API, every item: docs.rs/pixelactions-core
Some modules are pub and not part of this API — key-chord parsing,
display-server detection, the Wayland screencast space and the Windows
virtual-desktop grid. They are public only because the binary is a
separate crate and can reach nothing else. They carry #[doc(hidden)],
do not appear on docs.rs, and are not covered by this crate's
versioning.
Testing
| Layer | What it covers |
|---|---|
| Unit tests | every module — 90% line coverage floor per module, enforced in CI |
| Property tests | the conversion, because a bug there means clicking the wrong place |
| Doctests | every example in this file compiles and runs — the README is the crate docs |
Examples here are include_str!'d into the crate and run on every push, so
one that stopped compiling would fail CI rather than mislead you.
Relationship to the other crates
pixelactions the binary is this crate plus an input backend: CGEvent,
SendInput, XTEST, or the Wayland portal. Anything decidable without
touching a device lives here.
pixelcoords-core owns the geometry and the session schema; this crate
depends on it and never reimplements it. Matching, capture and shapes
belong there. What belongs here is everything about acting: the space a
platform's input API expects, the vocabulary of steps, and the report.
Also by nolindnaidoo
Rust
- pixelcoords - Mark pixel-exact coordinates machines can use · pixelcoords.dev
VS Code Extensions — every tool in the family, one page: letools.dev
- String-LE - Extract string values for i18n from JSON, YAML, CSV, TOML, INI, and .env
- Numbers-LE - Extract numeric values from JSON, YAML, CSV, TOML, INI, and .env
- EnvSync-LE - Spot missing keys across your .env files, with a markdown report
- Paths-LE - Extract file paths from JS/TS imports, JSON, HTML, CSS, TOML, CSV, and .env
- Secrets-LE - Detect and sanitize credentials locally, before you commit
- Scrape-LE - Check whether a page is scrapeable before you write the scraper
- Colors-LE - Extract and analyze colors from CSS, SCSS, LESS, Stylus, HTML, JS/TS, and SVG
- URLs-LE - Extract URLs from documentation, configs, and code
- Regex-LE - Find, test, and validate the regex patterns in the current file
- Dates-LE - Extract and analyze dates from logs, configs, and code
Contact Developer — GitHub · LinkedIn
License
MIT — see LICENSE.