Automate macOS native applications using AppleScript and System Events

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

Steps

  1. Open Script Editor (in /Applications/Utilities) or run scripts via osascript in Terminal
  2. Target an application by name: tell application 'Finder' to activate
  3. Interact with GUI elements via System Events: tell application 'System Events' to tell process 'Finder' to click button 'OK' of window 1
  4. Read and set text field values: tell application 'System Events' to set value of text field 1 of window 'My App' to 'hello'
  5. Use keystroke for apps without accessible UI controls: tell application 'System Events' to keystroke 'v' using command down
  6. Run from Terminal for automation pipelines: osascript -e 'tell application "Calendar" to quit'

Known gotchas

Related routes

Click UI elements in a non-scriptable macOS app via AppleScript GUI Scripting through System Events
desktop-automation · 6 steps · unrated
Automate macOS applications using AppleScript via osascript from the command line or scripts
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,600+ 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