Skip to content

feat: click-xy / dblclick-xy — screen-coordinate clicks for non-AX UIs - #1

Open
maxesisnclaw wants to merge 1 commit into
andelf:mainfrom
maxesisnclaw:feat/click-xy
Open

feat: click-xy / dblclick-xy — screen-coordinate clicks for non-AX UIs#1
maxesisnclaw wants to merge 1 commit into
andelf:mainfrom
maxesisnclaw:feat/click-xy

Conversation

@maxesisnclaw

Copy link
Copy Markdown

Motivation. Some macOS apps draw UI controls outside the Accessibility tree — proprietary financial / trading clients, canvas-based widgets, custom-rendered toolbars. click <selector> can't reach them. The existing mouse click X Y route works but goes through CGEventPost(HIDEventTap), which steals focus and moves the system cursor.

click-xy X Y exposes the existing SWaveAX background-click recipe (already implemented in mouse_click_bg, but previously only reachable via AX selectors) at raw coordinates.

Surface. axcli click-xy <X> <Y> [--strategy auto|cg|hid|cg-pid] [--window <ID>] [--activate]. Default strategy auto → cg-pid, identical to click <selector>'s default. --window lets callers override window selection; without it, the tool picks the visible AXWindow whose frame contains (X, Y), falling back to the first visible window. dblclick-xy mirrors the same API.

Validated on a real-world AppKit app with custom-drawn buttons that have zero AX exposure. Click delivered to the target window while the app was occluded behind another; foreground app and cursor position unchanged.

AI assistance. Implementation drafted with Claude (Opus 4.7) assistance, reviewed and tested by hand. No cargo clippy regressions on new code.

Adds two new subcommands that bypass AX selectors and click directly at
(X, Y) screen coordinates via CGEventPostToPid. Targets self-drawn /
non-AX UIs (canvases, custom-rendered controls, proprietary financial
clients) that 'click <selector>' can't reach.

Window resolution:
  1. --window <CGWindowID> if provided.
  2. The visible AXWindow whose frame contains (X, Y).
  3. First visible AXWindow of the app.

Strategies:
  - auto (default) / cg-pid: SWaveAX recipe via mouse_click_bg /
    mouse_dblclick_bg — background-safe, no focus steal, no cursor jump.
  - cg / hid: global CGEventPost(HIDEventTap), equivalent to
    'axcli mouse click X Y'. Pair with --activate for foreground.

Verified on 东方财富 Mac client (com.emmac.mac) — clicks on self-drawn
trade-panel buttons (无 AX 元素) succeed while the app is fully background
behind Brave Browser. Brave stays frontmost, no cursor movement, sell
tab toggles via cg-pid.

Implementation drafted with AI assistance, manually reviewed and tested.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant