Subject: Re: bug#32888: 27.0.50; Cannot access other apps via applescript on Mojave

From: Alan Third <[email-masked]>
Date: Sun, 30 Sep 2018 19:41:38 +0100

On Sun, Sep 30, 2018 at 11:08:03AM -0700, Aaron Jensen wrote:
> 
> Launch Chrome and open a webpage
> 
> emacs -Q
> 
> eval:
> 
> (do-applescript
> 	  (concat
> 	   "set frontmostApplication to path to frontmost application\n"
> 	   "tell application \"Google Chrome\"\n"
> 	   "	set theUrl to get URL of active tab of first window\n"
> 	   "	set theResult to (get theUrl) & \"::split::\" & (get name of window 1)\n"
> 	   "end tell\n"
> 	   "activate application (frontmostApplication as text)\n"
> 	   "set links to {}\n"
> 	   "copy theResult to the end of links\n"
> 	   "return links as string\n"))
> 
> I get "AppleScript error 1", but I'd expect to get the url and title of
> the page open in Chrome (try it in Script Editor).
> 
> This code is from org-mode's org-mac-grab-link
> 
> I'm guessing this has to do with the new permission sandbox stuff,
> though I don't know what Emacs needs to do to properly ask for permission.

Try adding this to the Info.plist:

        <key>NSAppleEventsUsageDescription</key>
        <string>Emacs requires permission to send some event to another application.</string>

I’ve no idea if it’s in the right format or anything...
-- 
Alan Third