Expand description
What Desktop does to a native app’s window: mapping a point in a
screenshot to the screen, reading a key chord, and (on Windows) sending
the input (docs/specs/SPEC_DESKTOP_DRIVING_2026_10_20.md §5.1–5.2).
Everything before win is plain logic, tested on every platform. The
rules it enforces are the spec’s defence against a stale or invented
coordinate landing on the wrong thing: a point is relative to the image the
last look returned, and it is refused if the window moved or resized
since, or the point is outside the window.
Modules§
- win 🔒
- Other platforms: the tool answers that driving is Windows-only for now (spec §8, phases 3 and 4).
Structs§
- Chord 🔒
- A key chord such as
ctrl+shift+s: modifiers held, then one key. - Look 🔒
- What the last
lookat a window returned: where the window was, and the size of the image the agent was shown. Clicks are in that image’s pixels. - Rect 🔒
- A window’s place on the screen, in physical pixels.
- Region 🔒
- A region of the last look, in that look’s pixels, to be shown zoomed.
Enums§
- Drag
Step 🔒 - What a drag does to the mouse and keyboard, one step at a time, for
run_dragto hand to whatever sends it.
Constants§
- DRAG_
DROP_ 🔒MS - Pause on the last point before the release, so a drop target registers.
- DRAG_
MIN_ 🔒MOVES_ PER_ LEG - Every leg of a drag has at least this many moves.
- DRAG_
PIXELS_ 🔒PER_ MOVE - Roughly one move per this many pixels, so an app that samples the pointer sees a path, not a jump.
- DRAG_
PRESS_ 🔒MS - Pause after the press, before the first move: an app that starts a drag on the first motion needs to have seen the press.
- DRAG_
SETTLE_ 🔒MS - Pause after the pointer arrives and the modifiers go down, before the press.
- DRAG_
STEP_ 🔒MS - Pause between moves.
- MAX_
DRAG_ 🔒MOVES - The most mouse moves one drag sends, however far it goes.
- MAX_
DRAG_ 🔒WAYPOINTS - A drag passes through at most this many given points besides its two ends.
- MAX_
IMAGE_ 🔒EDGE - A screenshot is scaled to at most this on its long edge.
- MAX_
TEXT_ 🔒CHARS typetakes at most this many characters.- MAX_
WAIT_ 🔒MS waittakes at most this long.- MAX_
ZOOM 🔒 - The most a region is enlarged.
- MIN_
REGION 🔒 - The smallest region
lookzooms into: smaller is not worth an image. - VK_
CONTROL 🔒 - VK_MENU 🔒
- VK_
SHIFT 🔒
Statics§
- LOOKS 🔒
Functions§
- check_
of_ 🔒look - Whether coordinates the agent says come from look
ofcan be used: they can whenofis the window’s latest look. Otherwise the answer says which look is the latest, and whether its size differs from the one the coordinates came from, so the agent knows they are stale. - check_
region 🔒 - A region inside
look’s image, or why not. - check_
text 🔒 type’s text must be non-empty, short, and free of control characters other than newline and tab.- describe_
scale 🔒 - What a
looksays about how its image relates to the window and to the look before it: the scale (window pixels per image pixel), and a warning when the image’s size changed since the last look of the same window. - drag_
path 🔒 - The screen points a drag moves through, from
starttoendby way ofvia, in order. Each leg is cut into short steps (the last step of a leg lands exactly on its end), and the whole drag is at mostMAX_DRAG_MOVESmoves. The first point isstartitself. - key_
code 🔒 - The virtual-key code of a key name, or
None. - last_
look 🔒 - What the last
lookat windowidshowed, if there was one. - parse_
hold 🔒 - The modifiers
dragmay hold while it drags: ctrl, alt and shift, written like a chord without a key (ctrl+shift). The Windows key is refused for the same reasonkeyrefuses it. - parse_
keys 🔒 - Read a chord. The Windows key is refused: a chord with it acts on the operating system (Run, the Start menu, lock), not on the app the user allowed.
- remember_
look 🔒 - Remember what
lookshowed of windowid, as the look after the one before it. Returns the look as stored (numbered) and the one it replaced. - run_
drag 🔒 - Hold
modifiers, press the button at the first point, move through the rest, pause, and let go at the last.outdoes each step. Whatever was pressed is let go again on every exit, including when a step fails: the button first, then the modifiers in reverse, so a failed drag never leaves one held. The first error is the one returned. - scaled_
size 🔒 - The size a
w×hwindow is shown at: its long edge at mostMAX_IMAGE_EDGE, never enlarged. - to_
absolute 🔒 - A screen point as
SendInputwants it withMOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_VIRTUALDESK: 0..=65535 across the whole virtual screen, which starts at (vx,vy) and isvw×vhpixels. - to_
screen 🔒 - The screen point for image point (
x,y) oflook, given where the window isnow. Refuses, with a reason the agent can act on, when the window moved or resized since the look or the point is outside the image. - zoom_
for 🔒 - How much a
w×hregion is enlarged: up toMAX_ZOOM, and not pastMAX_IMAGE_EDGEon its long edge. Never below 1.