Archive for October 25, 2013

Friday, October 25, 2013 [Tweets] [Favorites]

AppleScript and Mavericks

Mac OS X Automation covers new AppleScript features in Mavericks:

iCloud Document Support:

In OS X v10.9 or later, when you create or change documents using the AppleScript Editor or Automator applications, iCloud can keep the scripts, workflows, and applets up to date in those editors on your other Macs.

Applet Code Signing:

Code Signing support has been added as an export feature to both the AppleScript Editor and Automator applications, enabling Apple developers to easily generate signed copies of their applets and droplets.

AppleScript Libraries:

AppleScript Libraries provide a new plugin architecture for extending the power and abilities of AppleScript. AppleScript Libraries are user-created script files and bundles, composed in AppleScript or AppleScript/Objective-C, which contain specialized commands that can be referenced in scripts to provide extra or “missing” functionality.

The “use” Statement:

For its 20th anniversary debut in OS X Mavericks, AppleScript delivers a long-sought ability: an import command — dramatically extending the scope and power of this unique language.

A new AppleScript construct, called the “use statement”, imports the terminology and functionality of AppleScript Libraries and scriptable Applications through a simple single-line declaration placed at the top of a script, such as: use application "Finder", or: use script "My AppleScript Text Library".

System Notifications Support:

No longer will scripts and workflows have to display dialogs to inform users that time-consuming or complex automation processes have completed. With integrated notification support for AppleScript and Automator, users can leave their automation processing unattended, confident that they will be notified of the results in the built-in Notification Center.

Accessibility Preferences and GUI Scripting:

In OS X Mavericks, security controls are more granular, requiring the individual addition of applications, or automation applets that script the accessibility frameworks, to an approval list, displayed in the Security & Privacy system preference pane.

Interleaved Syntax:

In OS X 10.9, AppleScript introduces an alternative syntax for calling handlers and methods. Instead of using underscores and running the terms together, like this:

theString's writeToFile_atomically_encoding_error_(thePath, true, current application's NSUTF8StringEncoding, missing value)

You use an interleaved syntax similar to Objective-C, like this:

theString's writeToFile:thePath atomically:true encoding:(current application's NSUTF8StringEncoding) |error|:(missing value)

This is great for AppleScriptObjC. Unfortunately, although you can use the interleaved syntax for your own handlers in regular AppleScripts, you still cannot call into the Cocoa frameworks from regular AppleScripts (like you can via the PyObjC and RubyCocoa bridges).

Don Southard:

Most of all, I am happy to see Apple putting a focus on the power user with these enhanced automation tools and I hope it is a sign of the bright future OS X still has had of it.

Dr. Drang:

But improvements in the AppleScript language itself are like the proverbial tree falling in a forest. If no applications bother to use AppleScript, do those improvements exist? Not in any practical sense. No one in their right mind uses AppleScript as a standalone language; it’s all about adding functionality to an app or acting as glue between apps.

Mavericks, Gmail, Apple Mail, and MailMate

Benny Kjær Nielsen:

Recently, I implemented a workaround in MailMate for the problem of multiple labels. It is currently an experimental solution and you can enable it following the instructions in the release notes for version 1.7. In short, MailMate can be told to handle specific Gmail labels as if they were tags. If a label is handled as a tag then MailMate automatically ignores the corresponding IMAP mailbox. Tags are already supported by MailMate (no integration with Mavericks yet) and uses IMAP keywords on standard IMAP servers. An added benefit of this is that you can move messages between Gmail accounts and other IMAP accounts and the tags are preserved. This is great if you are planning to migrate…

PDF Downloads Broken in Safari on Mavericks

I’ve long used the WebKitOmitPDFSupport default so that Safari would download PDF files rather than display them in the browser window. In Mavericks, there’s a bug where this causes Safari to display the raw data of the PDF file. You can prevent this by entering these commands in Terminal go back to the default behavior:

defaults write WebKitOmitPDFSupport -bool NO
killall -SIGTERM cfprefsd

I found that the killall was necessary, even if Safari was not running, in order to make the change stick. Logging out might also work.

When Safari is displaying a PDF file, there are two main ways to save it to disk:

I’m not aware of any built-in way to auto-download PDF files without either of these extra steps. If there’s a link to the PDF file, you can Option-click it, but often there is no visible link.