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
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`
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`
Trigger menu commands the same way when there's no button target: `click menu item "Pin Tab" of menu "Window" of menu bar 1`
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
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
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
Accessibility permission is granted per calling process — enabling it for Script Editor does not also enable it for Terminal or for a script exported as a standalone app; each host needs its own explicit grant
UI element hierarchies (button/window/toolbar indices and accessibility descriptions) are not a stable public API and commonly break across app version updates, unlike a real AppleScript dictionary
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?