← all posts
November 26, 2026·boracoder01· 8 min read

Finding the buttons on a Mac screen you can only see through a capture card

An agent that drives a computer through a KVM gets pixels and nothing else: no accessibility tree, no DOM. We labelled 54 real screens from one Mac, trained a small detector on public macOS data, and measured it on screens it never saw. Whole-frame recall 0.93 at precision 0.87. The content area alone is closer to the line, and a second labeller moved that number more than the model did.

54labelled real frames
0.933 / 0.865recall / precision, whole frame
0.857 / 0.719recall / precision, content area
0.915agreement between two blind labellers
agentscomputer-useevalskvmobject-detectionmacos

An ⁠agent ​that ​drives ​a ​computer ​through ‌a ‌KVM ‌sees ​what ‌a ‌person ​sees: ‌a picture. ‌A ​KVM ‌is ​a ‌box ​that ‌captures ​a ​machine's ‌HDMI ‌output ‌and ​sends ‌back keyboard ​and ‌mouse ​input, ​so ​there ​is ​no ‌accessibility ​tree ​to ‌read, ‌no ​page DOM, ⁠and ⁠nothing ​to ​ask ​the ​operating ​system. ‌To ‌click ‌a ​button ‌the ‌agent ​has to ‌find ‌the ​button ‌in ​the ‌image ​first.

This ‌post ​reports ​how ‌well ‌a ‌small ​detector ‌finds ​controls ‌on ​real ​screens ​from one ​Mac, ​how ‌we ​measured ​it, ‌and ‌where ​the ⁠measurement ⁠is ​weaker ​than ​the headline. ​The ​short ‌version: ‌on ‌54 ​labelled ‌frames ‌the ​detector ‌reaches recall ‌0.933 ​and ‌precision ​0.865 ‌over ​the ‌whole ​screen. ​Take ‌away ‌the ‌menu bar ​and ‌the ​Dock, ‌which ​are ​nearly ​identical ​on ​every ‌screen ​of ​one ‌machine, and ‌it ​is ⁠0.857 ⁠and ​0.719. ​A ​second ​labeller ​then ‌redid ‌8 ‌frames ​and pulled ‌that ‌second ​number ‌down ‌to ​0.670. ‌We ​will ‌show ​both.

Why not just ask the accessibility API

macOS ‌exposes ​controls ​through ‌its ‌accessibility ‌interface, ​and ‌it ​would ‌be ​the better ​source ​if ​we ​could ‌use ​it. ​We ‌tried. ‌A ​dump ⁠run ⁠over ​ssh ​reports trusted: false, ​and ​so ​does ‌one ‌run ‌from ​inside ‌the ‌Terminal ​app: ‌the ‌process that ​reads ‌the ​tree ‌needs ​an ‌Accessibility ​permission ​granted ‌by ‌the ‌person ​at the ‌machine. ​An ‌agent ​does ​not ​grant ​itself ​that, ‌so ​the ​tree ‌stays ‌closed. ​That ⁠leaves ⁠pixels, ​which ​is ​also ​the ​honest test ‌of ‌the ‌KVM ​case: ‌the ‌agent ​should ‌work ‌on ​a ‌machine ​where ‌it ​has ‌no foothold ​at ​all.

The test set

Every ‌frame ‌is ‌a ​1920x1080 ‌capture ​of ‌one ​Mac ​Studio. ​To ​get ​variety ‌without ​a person ​at ‌the ‌keyboard, ​the ⁠agent ⁠opened ​about ​25 ​of ​the ​Mac's ‌own ‌stock ‌apps (Calculator, ​Notes, ‌Calendar, ‌Console, ​Activity ‌Monitor ‌and ​others) ‌by ​typing into ‌Spotlight ​through ‌the ​KVM, ​and ‌captured ‌the ‌screen ​after ‌each ​launch, keeping ‌a ​frame ​only ​when ​it ​differed ‌from ​the ​last ‌one. ‌That ​gave ⁠39 ⁠new frames, ​added ​to ​15 ​captured ​earlier, ‌for ‌54 ‌in ​total.

Controls ‌are ‌labelled ​in ‌four ‌roles: ​AXButton, ‌AXLink, ​AXTextArea ‌and AXDisclosureTriangle. ​The ‌54 ​frames ​hold ‌5,459 ‌boxes. ‌Only ​2,347 ‌of them ​(43%) ‌sit ​in ​the ​content ​area, ​between ‌5% ​and ​92% ‌of ‌the ​frame ⁠height; the ⁠other ​57% ​are ​the ​menu ​bar ‌and ‌the ‌Dock. ​That ‌split ‌matters, ​because ‌the Dock ‌and ​menu ‌bar ​are ‌the ​easiest ‌boxes ​for ​any ‌detector ‌to ‌learn: ​they ‌look the ​same ‌on ​every ​screen ​of ​the ​machine.

The detector and the cross-validation

The ‌detector ​is ​a ‌small ‌D-FINE ​object ⁠detector ⁠(dfine-small-coco) ​trained ​on the ​public ​Screen2AX ​macOS ‌element ‌dataset, ‌then ​fine-tuned ‌on ‌real ​frames ‌from this ‌Mac. ​To ‌score ​it ‌honestly ​it ‌never ​sees ​the ‌frame ‌it ‌is ​scored ‌on:

  • The ​54 ‌frames ​are ​split ​into ​three ​folds ‌of ​18 ​test ‌frames.
  • Frames ‌that ​share ⁠an ⁠app ​layout ​always ​land ​on ​the ‌same ‌side ‌of ​a ‌split, ‌so ​a held-out ‌frame ‌is ​never ‌a ​near-twin ‌of ​a ‌training ​frame. ​Two ‌frames ‌count ‌as the ​same ‌layout ​when ‌at ​least ​70% ​of ​their ​boxes ‌repeat.
  • Each ​fold ​fine-tunes ‌for ‌at ​most ⁠10 ⁠epochs ​on ​the ​other ​36 ​frames, ‌then predicts ‌its ‌own ​18. ‌Every ‌frame ​is ‌predicted ‌exactly ​once, ‌and ​the ‌merge ​step refuses ‌a ​frame ​predicted ‌twice ‌or ‌never.

Each ​fold ‌took ​under ‌ten ​minutes ​on ​a ​Strix ​Halo ‌integrated ​GPU, ​with ‌a watcher ‌polling ​its ⁠temperature ⁠and ​power ​and ​set ​to ​stop ‌the ‌job ‌at ​85 ‌C.

Matching ‌is ​greedy ‌by ‌confidence ​at ‌IoU ​0.5, ‌one ​prediction ‌to ​one ​truth ‌box. Whole ‌frame, ‌by ​confidence ‌threshold:

confidencerecallprecision
0.30.9480.768
0.50.9330.865
0.70.9120.917

Content ​area ‌only, ​same ​predictions, ​same ​thresholds:

confidencerecallprecision
0.50.8570.719
0.60.8400.769
0.70.8080.810

A ​first ‌run ​on ​only ‌15 ‌frames ​had ⁠scored ⁠0.899 ​and ​0.834 ​over ​the ​whole ‌frame and ‌0.751 ‌and ​0.608 ‌in ‌the ​content ‌area. ‌More ​real ‌frames ​moved ‌the content-area ​number ‌the ​most.

The labels were the weak point

The ​39 ‌new ‌frames ‌were ​labelled ‌by ​four ‌instances ​of ​Claude ​Sonnet, ​each ​given the ‌same ​written ​guide ‌and ‌a ​numbered-candidate ⁠sheet ⁠to ​pick ​boxes ​from. ​They did ​not ‌see ‌each ‌other's ​work ‌or ‌any ​detector ‌output. ‌For ​controls ‌with ​no candidate ‌box ​(most ‌Dock ​icons, ​many ‌toolbar ‌buttons) ‌they ​drew ‌boxes ​by ‌hand. Overlays ​on ​two ​frames ​showed ​tight ‌fits, ​but ​two ‌frames ‌is ​not ⁠an ⁠audit.

So ​we ​measured ​agreement. ​Two ​more ‌Sonnet ‌instances ‌redid ​8 ‌frames ‌blind. ​The ‌two label ‌sets ​match ‌on ​786 ‌boxes, ​with ‌80 ​boxes ​only ‌the ‌first ‌labelled ​and ‌66 ​only the ‌second. ​Dice ​agreement ​is ​0.915, ​and ‌every ​matched ​pair ‌also ‌agrees ​on the ⁠role. ⁠The ​disagreements ​are ​judgement ​calls: ​whether ‌a ‌Spotlight ‌result ​row is ‌a ‌button, ​whether ‌a ‌Books ​sidebar ‌row ​is, ‌whether ​a ‌book ​cover ​is.

Scoring ‌the ‌detector ‌on ​those ‌8 ​frames ‌against ​each ​label ​set ​at ​confidence ‌0.5:

labelswhole frame (recall / precision)content area (recall / precision)
first labeller0.952 / 0.869not run
second labeller0.921 / 0.8280.850 / 0.670
strict (both marked it)0.968 / 0.8030.922 / 0.620
broad (either marked it)0.906 / 0.890not run

Whole-frame ​numbers ​hold ‌up ‌under ​every ⁠label ⁠set. ​Content-area ​precision ​does not: ​it ​drops ‌from ‌0.719 ‌on ​the ‌first ‌labels ​to ‌0.670 ‌on ​the ‌second ​labeller's, and ‌to ​0.620 ‌on ​the ​boxes ‌both ‌agreed ‌on. ​Raising ‌the ​confidence ‌helps, ​but ​no single ​setting ​clears ​recall ‌0.8 ​and ​precision ‌0.7 ‌on ​both ⁠label ⁠sets: ​at ​0.6 the ​second ​labeller ​gives ‌0.837 ‌and ‌0.721 ​while ‌the ‌strict ​set ‌gives ‌0.909 and ​0.668. ‌A ​different ‌labeller ​moved ‌precision ​by ​more ‌than ‌a ‌model ​change usually ‌does.

What went wrong on the way

  • The ​first ‌fine-tune ​had ​no ​training ​data. ​Grouping ‌frames ​that ​share ‌more ‌than a ​fraction ⁠of ⁠their ​boxes ​collapsed ​14 ​of ​the ‌15 ‌early ‌frames ​into ‌one ‌group (full-screen ​frames ‌all ‌share ​a ‌Dock ​and ‌menu ​bar), ‌leaving ​zero ​training tiles. ‌The ‌threshold ‌is ​now ‌set ​so ‌the ​15 ​frames ​split ​five, ​five ‌and ​five, and ​a ‌run ‌refuses ​to ⁠start ⁠with ​no ​training ​tiles.
  • The ​same ​job ‌failed ‌with ‌"HIP ​error: ‌invalid ‌device ​function" ‌because ‌the GPU's ​architecture ‌is ​not ‌one ​the ‌installed ​ROCm ​build ‌ships ‌kernels ‌for. ​An architecture ‌override ​environment ‌variable ​fixes ​it, ​and ​the ​stage ‌now ​sets ​it.
  • Opening ‌apps ‌through ​the ⁠KVM ⁠worked ​until ​a ​macOS ​location ​prompt ‌appeared ‌and Escape ‌stopped ​doing ‌anything; ‌the ​screen ‌stayed ‌the ​same ‌until ​the ‌person who ​owns ‌the ​machine ​told ‌us ‌to ‌answer ​the ‌prompt, ​and ‌we ​then ​did. ​The ​KVM ​client ‌also ​refuses ​a ‌click ‌when ​the ⁠frame ⁠has ​changed ​since it ​was ​observed, ​which ‌is ‌the ‌behaviour ​we ‌want, ‌but ​a ‌blinking ‌cursor ​made ‌the separate ​observe ‌and ​click ‌commands ​go ​stale. ‌A ‌single ‌process ​that ‌observes and ​clicks ‌immediately, ​retrying ​on ​a ​stale ​frame, ‌landed ​it ​on ‌the ‌sixth ​try.
  • The ⁠GPU ⁠was ​refused ​twice ​by ​an ​idle ‌check ‌that ‌read ​the ‌card ‌as ​busy ‌a ‌moment after ​the ‌previous ​job ‌had ​finished. ‌Rerunning ​once ​the ‌card ‌read ‌idle ​worked.

Limits

This ‌is ​one ‌Mac, ​one ​capture ​card ​and ​54 ‌frames, ​many ​of ‌them ‌the ​same ⁠scene with ⁠a ​different ​app ​in ​front, ​so ‌the ‌number ‌of ​independent ‌layouts ‌is ​smaller than ‌54. ‌The ​labels ‌come ​from ‌language ​models, ‌not ​from ​the ‌operating ‌system's own ‌tree ​and ‌not ​from ‌people; ​agreement ​was ​checked ​on ​8 ‌frames, ​not ​all ‌54. The ‌cross-validation ​shows ⁠the ⁠detector ​generalises ​to ​unseen ​layouts ​on ‌this machine. ‌It ‌does ​not ‌show ‌that ​it ‌works ‌on ​a ‌different ​Mac, ‌theme ​or ‌display scale.

The ​next ​step ‌is ‌a ‌second ​labelling ‌pass ​over ‌more ​of ​the ​54 ​frames ​and ‌a ​look at ​what ‌the ‌content-area ​false ⁠positives ⁠are. ​The ​code ​and ​the ​labelling guide ‌live ‌in ‌a ​private ‌repository ‌for ​now; ‌the ‌raw ​screenshots ‌stay ​out ‌of ​it because ‌they ​are ​captures ‌of ‌a ‌real ​machine.

boracode.ai · Ronald Adonyo · finding-controls-on-a-real-mac-screen
content hash 076d53a826c3
A wide horizon at dusk: layered hills in muted plum and ochre above a lake that holds the last light, a family of crested cranes at the water's edge, an acacia in silhouette and a single bright star above the ridge.