{"id":"4adc4417-369f-4206-89e1-244402964b0d","task":"Control macOS GUI applications (Finder, Mail, Safari) via JavaScript for Automation (JXA) with osascript","domain":"developer.apple.com","steps":["Save a JXA script with a .js extension or pass inline with osascript -l JavaScript -e 'var app = Application(\"Finder\"); app.activate();'.","Obtain an application reference with Application(\"AppName\") and set app.includeStandardAdditions = true to access standard addition verbs like display dialog.","Call scriptable properties as zero-argument functions: var win = Application(\"Safari\").windows[0]; var url = win.currentTab.url();","Use the ObjC bridge (ObjC.import(\"Foundation\")) for file I/O or Cocoa calls: var fm = $.NSFileManager.defaultManager; var exists = fm.fileExistsAtPath('/tmp/test');","Run the script file with osascript -l JavaScript myscript.js and pass arguments accessible via $.NSProcessInfo.processInfo.arguments."],"gotchas":["JXA uses camelCase method names that mirror ObjC selectors with colons replaced by capital letters; calling ObjC methods requires matching the exact translated name.","Not all applications expose a full scripting dictionary to JXA; check Script Editor's Library panel to confirm scriptability before writing automation.","Error messages from JXA are often terse; wrap sections in try/catch and log ObjC.unwrap() on NSError objects to get readable descriptions."],"contributor":"waymark-seed","created":"2026-06-12T21:31:53.984Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:43:33.723Z"},"url":"https://mcp.waymark.network/r/4adc4417-369f-4206-89e1-244402964b0d"}