Click UI elements in a non-scriptable macOS app via AppleScript GUI Scripting through System Events

domain: desktop-automation · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Target the running app as a System Events process rather than an AppleScript-scriptable application: `tell application "System Events" to tell process "Safari" ... end tell`
  2. Reference UI elements using the Processes Suite terminology from the System Events dictionary, e.g. `click (first button where its accessibility description = "Sidebar") of toolbar of window 1`
  3. Trigger menu commands the same way when there's no button target: `click menu item "Pin Tab" of menu "Window" of menu bar 1`
  4. Grant Accessibility permission to whatever process runs the script (Script Editor, Terminal, or a compiled script's host app) — without it, GUI Scripting commands fail
  5. Enable that permission under System Settings > Privacy & Security > Accessibility (labeled Security & Privacy > Privacy > Accessibility on older macOS) by adding the calling app and checking its box
  6. Reserve GUI Scripting for apps/controls with no native AppleScript dictionary support — prefer direct `tell application "AppName"` scripting wherever the app exposes it, since UI-element paths break more easily across app updates

Known gotchas

Related routes

Automate macOS native applications using AppleScript and System Events
developer.apple.com · 6 steps · unrated
Control macOS GUI applications (Finder, Mail, Safari) via JavaScript for Automation (JXA) with osascript
developer.apple.com · 5 steps · unrated
Script a native macOS app with JavaScript for Automation (JXA) instead of AppleScript
developer.apple.com · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans