# macOS Background Desktop Control

> Control native macOS apps and iPhone Mirroring with pure Swift scripts—background Accessibility actions, shadow-free single-window screenshots, Apple Vision OCR pixel centers, Retina coordinate scaling, smooth trackpad gestures, and clipboard-preserving paste.

macOS Background Desktop Control is a paid AI agent skill on Agensi by NaghtSieger, in Agents & Orchestration. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $14.99 (one-time purchase)
- Creator: [NaghtSieger](https://www.agensi.io/creators/naghtsieger)
- Category: [Agents & Orchestration](https://www.agensi.io/skills/agents-orchestration)
- Version: 1.0.0
- Last updated: 2026-12-04
- Security: scan passed (2026-12-04); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/macos-background-desktop-control
- Tags: ai-agents, automation, productivity, macos, computer-use, desktop-automation, vision-ocr, iphone-mirroring

## What it does

- Inspects macOS permissions, lock-screen state, display scaling, and open windows with zero helper apps
- Reads AXUIElement trees and clicks buttons, edits fields, or selects text in background windows silently
- Captures shadow-free single-window PNGs and runs local Apple Vision OCR for exact pixel click centers
- Converts 2x/3x Retina pixels to exact logical points for accurate clicks, drags, and trackpad scrolls
- Types Unicode directly or pastes via Cmd+V while backing up and restoring your original clipboard
- Includes a dedicated iPhone Mirroring recipe using continuous trackpad scroll phases and OCR targeting

## Who it's for

- **macOS developers & QA engineers:** Automated end-to-end GUI checks on native Mac apps without writing fragile UI test harnesses Try: "Inspect my open Safari window, click the Login button via Accessibility without moving my mouse, and confirm the next sc"
- **Power users automating Mac workflows:** Reliable control over apps with no API (accounting tools, Electron apps, Notes, Mail) without losing their clipboard Try: "Find the Export button in my open PDF app using Apple Vision OCR, click it, and paste this filename without overwriting"
- **iOS & mobile testers:** Hands-free navigation inside macOS iPhone Mirroring using continuous trackpad scroll and OCR tap centers Try: "Activate iPhone Mirroring, capture an OCR screenshot, scroll down smoothly, and tap the Settings row."
- **AI coding agent builders:** Zero-dependency pure Swift CLI scripts that work across Claude Code, Cursor, Codex CLI, Gemini CLI, and Antigravity Try: "Check my macOS Accessibility and Screen Recording permissions and list all open windows with their logical bounds."

## About this skill

Native macOS desktop apps rarely ship APIs, and most generic computer-use prompts fail on Retina coordinate scaling, steal your mouse cursor, overwrite your clipboard, or break completely on Electron apps and iPhone Mirroring.

### How it works
This skill gives your AI agent four focused, zero-dependency Swift scripts that run directly on macOS's built-in frameworks (`AppKit`, `ApplicationServices`, `CoreGraphics`, and `Vision`):
1. **Preflight & Window Discovery**: Checks Accessibility, Screen Recording, and lock-screen state (`SESSION_LOCKED` fail-closed guard) before listing open windows with their PID, bundle ID, and logical bounds.
2. **Background Accessibility First**: Walks the `AXUIElement` tree using deterministic element paths so the agent can press buttons, fill text fields, and select text in background windows without moving your mouse.
3. **Single-Window Capture + Apple Vision OCR**: Captures shadow-free single-window PNGs and extracts line-level English and CJK text bounding boxes and pixel centers locally via Apple Vision.
4. **Retina-Accurate Input & Gestures**: Converts Retina screenshot pixels to exact logical screen points automatically, emits continuous pixel-delta trackpad scroll phases (required by iPhone Mirroring), runs smooth HID drags, types Unicode directly, and restores your clipboard after paste.

### Frameworks & tools
Built purely on native macOS `swift` and Apple system frameworks (`AppKit`, `ApplicationServices`, `CoreGraphics`, `ImageIO`, `Vision`, `/usr/sbin/screencapture`). No external daemon, no third-party app installation, and no external API keys required.

### Why this beats prompting it yourself
Writing macOS GUI automation from scratch consistently trips over five subtle bugs: Retina 2x/3x pixel-to-point drift, discrete scroll wheel events being ignored by iPhone Mirroring, missing lock-screen guards, stuck modifier keys, and overwriting the user's clipboard during paste. Every one of these edge cases is pre-solved in battle-tested, compact Swift scripts with deterministic JSON output.

### Use cases
- Driving native macOS software that has no CLI or API
- Automating Electron, Chrome, or canvas-heavy desktop apps using local Apple Vision OCR
- Navigating and testing iOS apps through macOS iPhone Mirroring
- Verifying desktop UI regressions inside an AI coding agent session

### Known limitations
- Requires macOS 12+ with Xcode Command Line Tools (`swift` command available).
- The user must grant Accessibility and Screen Recording permissions to the terminal or AI coding app running the scripts.
- Some protected macOS surfaces ignore background PID-targeted synthetic clicks and require bringing the window to the foreground first (handled automatically by the skill's verify-and-fallback workflow).

## Requires

- Runs on macOS only
- Swift
- Accessibility permission
- Screen Recording permission

## Technical details

- **Scripts included** (each self-contained, under 16 KB, pure UTF-8 Swift):
  - `scripts/mac_windows.swift` (`capabilities`, `list-windows`, `activate`)
  - `scripts/mac_capture_ocr.swift` (`screenshot`, `ocr`)
  - `scripts/mac_ax.swift` (`tree`, `invoke`, `set-value`, `select-text`)
  - `scripts/mac_input.swift` (`move`, `click`, `scroll`, `drag`, `type-text`, `press-key`, `paste`)
- **Output format**: Single-line UTF-8 JSON on stdout; non-zero exit code with structured `{"ok":false,"error":"..."}` on failures (`exit 2` on `SESSION_LOCKED`).
- **Temporary files**: Screenshots are written to `--output` or system temporary storage and removed after verification. No persistent daemon or system config edits.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the macOS Background Desktop Control skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### Does this require installing any third-party app or background server?

No. It runs directly using macOS's built-in swift runtime and native Apple frameworks.

### Will it overwrite what I already copied to my clipboard?

No. The paste command backs up your existing clipboard text, sends Cmd+V, and restores your previous clipboard automatically.

### Does it work on Retina displays and multi-monitor setups?

Yes. Passing --window-bounds and --image-size from the screenshot JSON automatically converts 2x/3x Retina OCR pixels into exact logical screen coordinates across multiple displays.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
