Skip to main content
FlowDeck macOS UI automation drives native macOS apps using the Accessibility framework and CGEvent-based input. Commands live under flowdeck ui mac.

Common Flags

Most macOS UI automation commands support:
  • --app to target a specific app by name, bundle ID, or PID. Required on most commands. Examples: --app "Safari", --app "com.apple.Safari", --app "12345".
  • --json for machine-readable output.
  • --examples / -e to print usage examples for the command.
  • -h / --help for the help screen.
Leaf action commands (click, double-click, right-click, type, erase, key, hotkey, scroll, move, drag, swipe, find, list, wait, assert, launch, activate, quit, screen, window/menu subcommands, permission commands) accept only --json, --examples/-e, and -h beyond their command-specific flags. They do not accept -v/--verbose. Every command that can reach the cursor also takes --foreground. Actions run in the background by default — no cursor movement, no focus change — and --foreground opts out. drag, swipe, move, activate, and window focus have no background path and require it. See macOS Automation for the full rationale. Session subcommands (session start, session stop) additionally accept -v / --verbose. App resolution order:
  1. Numeric string → PID
  2. Contains a dot → bundle ID
  3. Otherwise → fuzzy match against running app names

Permissions

Capture

Query

Interaction

Keyboard

Wait and Assert

App Lifecycle

Window Management


Key Options Explained

Screen and Sessions

  • --output sets the screenshot file path (PNG). If omitted, FlowDeck writes to a temp file and prints the path.
  • --tree returns only the accessibility tree (no screenshot).
  • --mode (boolean; no value) captures the full screen instead of the app window. Use when the app window is partially offscreen or you need surrounding context (Dock, menu bar, other windows).
  • Screenshots require macOS 14+ and Screen Recording permission.
  • Screenshot dimensions are in pixels.
  • session start captures tree + screenshots every 500ms by default and writes to ~/.flowdeck/automation/mac-sessions/<session-short-id>/ (the short ID is the first 8 characters of the session UUID).
  • session stop takes no --app. At most one macOS UI session is active at a time, so stop is unambiguous.
  • Starting a session stops any active macOS session first.
  • --interval-ms and --retention-seconds tune capture frequency and retention (default 60s). Retention always keeps at least one capture.
  • Sessions write latest.json, latest.jpg, and latest-tree.json so automation can re-read the newest capture without listing the directory.
  • JSON output from session start includes the session directory, app name, PID, screens directory, trees directory, and the latest_screenshot / latest_tree paths.

Find

  • --by-id matches accessibility identifiers instead of labels.
  • --by-role matches element roles (e.g., button, textField).
  • --contains does a substring match against labels.
  • Returns element role, center coordinates, enabled state, and text value.
  • Suggestions are provided when no exact match is found.

Click, Double-Click, and Right-Click

  • --by-id treats the target as an accessibility identifier.
  • --point expects x,y coordinates (screen-absolute, matching find output).
  • Pass <target> or --point, not both. The command errors if you supply neither.
  • --duration on click is a long-press hold time in seconds.
  • tap and double-tap are hidden aliases for click and double-click.

Type and Erase

  • --clear clears the focused field before typing (Select All + Delete).
  • --delay-ms overrides the per-character typing delay.
  • --mask hides the typed text in terminal output and JSON (useful for passwords).
  • erase --characters 5 deletes a specific number of characters; omit to clear all.

Key and Hotkey

  • key --name accepts key names: return, escape, tab, delete, space, f1f12, arrow keys, etc.
  • key --keycode accepts raw virtual keycodes.
  • Pass --name or --keycode, not both. The command errors if you supply neither.
  • hotkey accepts modifier+key combos: cmd+s, cmd+shift+z, ctrl+alt+delete.
  • Command-key combos are unreliable against a backgrounded app. Whether a cmd+... combo lands depends on how the target app installs the shortcut, and a combo that doesn’t land is still reported as success. Use ui mac menu click "File > Save" when the result matters — it goes through accessibility and always works in the background — or pass --foreground after asking the user.
  • Supported modifiers: cmd/command, shift, ctrl/control, alt/option.

Scroll

  • --direction is required: up, down, left, or right.
  • --amount sets the scroll magnitude in discrete ticks (default: 3).
  • --smooth enables many small ticks with delays for smooth scrolling.
  • --until scrolls repeatedly until the target element appears. Use id:myElement for accessibility ID matching.
  • --timeout sets the deadline for --until in seconds (default: 30).
  • Scroll is performed at the center of the app’s focused window.
iOS ui simulator scroll --timeout is in milliseconds; macOS ui mac scroll --timeout is in seconds. Same flag, different unit — never copy values across platforms.

Move, Drag, and Swipe

  • move --point expects x,y screen-absolute coordinates.
  • move --app is optional. The cursor moves to the absolute screen point regardless of which app is focused; the flag only validates that the named app exists.
  • move, drag, and swipe are foreground-only: they take the real cursor, so they require --foreground and exit non-zero without it.
  • drag --from and --to expect x,y coordinates. --duration is in seconds (default: 0.5).
  • swipe --direction accepts up, down, left, right. --distance is in points (default: 200).

Wait

  • --condition accepts one of: exists (default), gone, enabled, stable. Invalid values are rejected with an error.
    • exists — element is present in the accessibility tree
    • gone — element is not present
    • enabled — element is present and enabled = true
    • stable — element’s frame stops moving between polls (use to wait for an animated transition to settle)
  • --timeout is in seconds (default: 30).
  • --by-id treats the target as an accessibility identifier.

Assert

Assert element conditions with immediate pass/fail (no polling). Exits with failure if the assertion does not hold. Subcommands: Common Options: Text Options:

App Lifecycle

  • launch uses --bundle-id, not --app. It targets the installed bundle directly, not a running process. Discover bundle IDs with ui mac list apps --json.
  • activate --app brings a running app to the foreground. It requires --foreground, because raising an app takes the user’s screen. You rarely need it: every action command already reaches a background app.
  • quit --app sends a graceful terminate. --force force-quits.

Window Management

  • --index selects which window (default: 0, the first/main window).
  • window move --to expects x,y for the new origin.
  • window resize --size expects w,h for the new dimensions.
  • menu list shows the app’s menu bar hierarchy with titles, shortcuts, and enabled state.
  • menu click navigates a menu path using > separators.

List

  • list apps shows running GUI applications with PID, name, and bundle ID.
  • --include-agents includes background agent apps.
  • --include-system includes system processes.
  • list windows requires --app.
  • list screens shows connected displays with frame and scale info.
  • list permissions shows Accessibility and Screen Recording status.

Coordinate System

  • All coordinates are screen-absolute points (matching what find returns).
  • Multi-display setups use the global coordinate space (origin at primary display top-left).
  • Do not apply Retina scaling; use coordinates as reported by find and list screens.
  • Use flowdeck ui mac list screens to see display layouts and pixel densities.

Coordinate Format

All point and size flags on macOS use comma-separated x,y (or w,h for sizes). Space-separated values are rejected with a live error:
Applies to --point, --from, --to, and --size across click, double-click, right-click, move, drag, window move, and window resize.

Timing Tuning

Set these environment variables to adjust input timing:
  • FLOWDECK_HID_STABILIZATION_MS adds settle time between input events (default: 25)
  • FLOWDECK_TYPE_DELAY_MS adds per-character typing delay (default: 1)

Performance and Reliability Tips

  • Start a session before any macOS UI work. Run flowdeck ui mac session start --app "MyApp" --json, parse the JSON output to get latest_screenshot and latest_tree, then read those files to inspect the current UI.
  • macOS UI sessions remain single-active and stop automatically when the owner process that started them exits. Set FLOWDECK_OWNER_PID to bind a session to a specific owner process.
  • Verify after every action. After each click/type/scroll, wait briefly, then re-read latest_screenshot and latest_tree to confirm the UI changed.
  • Use accessibility identifiers and --by-id whenever possible; label matching is slower and more ambiguous.
  • For automation loops, re-read latest-tree.json/latest.jpg from disk instead of issuing screen for every step. The session updates these files automatically.
  • Use ui mac screen --tree --json --app "MyApp" for one-off tree-only checks when you do not need a running session.
For a full help listing, run flowdeck ui mac --help.