The Robservatory

Robservations on everything…

 

Fix Messages’ broken bundled AppleScripts

While playing around with Messages this morning, I noticed that it ships with a feature that, if used, throws an error. Steps to reproduce:

  1. Open Messages’ preferences.

  2. Set the Applescript handler pop-up to any of the listed scripts:

  3. Close preferences, and try to send a message to anyone.

  4. Revel in the brokenness.

I especially like the execution error: No error message…it’s that rare non-error that tosses up an error dialog!

In any event, I think it’s shameful that Apple ships the app with a feature—plainly obvious in prefs—that breaks when used. Yes, I know AppleScript is probably dying, but that doesn’t excuse shipping the app with a clearly-broken feature; if it doesn’t work, just remove it. Apparently this has been an issue since Yosemite’s release in October of 2014!

With all that said, fixing this is incredibly easy—it took me about 30 seconds of “work” to find and fix the problem. If you’d like to use the bundled AppleScripts in Messages—either as is, or in some modified form—here’s what you need to do

In Messages’ prefs, select Open Scripts Folder from the AppleScript handler pop-up. Now open all six scripts in Script Editor (in Applications > Utilities). Find these four lines in each Apple-provided script (note I’ve removed the silly whitespace Apple included):

on received remote screen sharing invitation from theBuddy for theChat	
end received remote screen sharing invitation
on received local screen sharing invitation from theBuddy for theChat
end received local screen sharing invitation

To fix the scripts, comment those lines out, which you do in AppleScript with two hyphens. After editing, that section should look like this:

--on received remote screen sharing invitation from theBuddy for theChat
--end received remote screen sharing invitation
--on received local screen sharing invitation from theBuddy for theChat
--end received local screen sharing invitation

Save the modified scripts, and the error message will vanish when you select a script in Messages’ preferences. I tested with the iTunes Remote Control script, and it worked fine after making the above edits. (Note for it to work, the chat that’s sending the iTunes commands can’t be the frontmost chat. If testing with a buddy, switch to another chat before they send the controlling commands.)

I assume there’s probably a better fix—those commands I commented out have probably been renamed—but I didn’t bother spending any time looking for that fix, because I’m not getting paid to fix Apple’s problems.

3 Comments

Add a Comment
  1. I seem to have only 5 AppleScripts in the folder:
    Auto Accept.applescript
    Auto Decline.applescript
    iTunes Remote Control.applescript
    Mix Message Case.applescript
    Speak Events.applescript

    Did you create the Alert on Available script?

    1. I did – that’s what actually started me on this route. This used to be a standard feature, but it went away when Apple decided always-on Messages was the thing to have. I was trying to recreate it, though never got it to work.

      -rob.

  2. Error -1708 means a command couldn’t be handled. AppleScript is hopelessly vague about where an error originated (no such thing as stack traces), so you need to make sure it’s not being caused by any of the commands your script sends itself, but from your description I reckon it’s the initial received remote screen sharing invitation command that’s sent by Messages to your script that’s not being handled.

    I don’t use Messages myself, but from what I remember of Mail action scripts, the Mail devs designed it so that if your attached script defined a perform mail action with messages handler, Mail would call that, passing a list of messages and other information for your handler to work with. If the attached script doesn’t contain that handler, Mail just sends a basic run command that executes any top-level statements in your script, which is fine if you don’t care about the details.

    Sounds like the Messages devs have taken the same approach, only they’ve screwed up the implementation that causes the perform mail action with messages notification to miss your script’s perform mail action with messages handler. It’s probably a really stupid trivial bug too, such as the ObjC code that sends the received remote screen sharing invitation command to the script not using the exact four-char codes given in Messages’ dictionary. In which case it’s a 30-second fix, not counting the years of bureaucracy it takes to action it first!

Leave a Reply

The Robservatory © 2017 Built from the Frontier theme