This Week's Sponsor:


Ensure that if a device isn’t secure it can’t access your apps.  It’s Device Trust for Okta.

Posts tagged with "applescript"

iTunes 11.0.3 Supports AirPlay Speaker Control Via AppleScript

Also new in iTunes 11.0.3 is an update to the app’s AppleScript dictionary that adds support for controlling AirPlay speakers. The AppleScript additions contain several options: you can check on an AirPlay device’s name, activity, availability on the network, kind (computer, Apple TV, other AirPlay device, etc), network address, and even if it supports audio or video.

This is a particularly welcome addition as it has been requested by users willing to script iTunes’ speakers for years now. Previously, the best option was to rely on GUI scripting to enable/disable speakers; as I wrote in December, it’s good to see Apple is still actively supporting AppleScript on OS X.

Doug Adams has already put together a basic AirPlay script for iTunes 11.0.3.

Integrating OmniFocus and Reminders On OS X

Integrating OmniFocus and Reminders On OS X

Daniel Jalkut and Sean Korzdorfer have been working on two aspects of the same problem: bridging the gap between OmniFocus and Reminders on OS X.

Sean put together a series of AppleScripts to send tasks from OmniFocus to Apple’s Reminders app for Mac. Daniel created (and open-sourced) an app to check Reminders for newly added items, transfer them to OmniFocus while keeping due dates, and deleting them from their original location in Reminders.

I love OmniFocus for both Mac and iOS, but it turns out that because I lean so heavily on using Siri to add items, I tend not to open OmniFocus while I’m on the go. When I come home and get to work on my Mac, I notice that OmniFocus doesn’t contain any of my recently added items, so I have to go through the cumbersome steps of opening my iPhone and launching OmniFocus just to get this theoretically time-saving trick to work right.

I have tried to get into using OmniFocus’ iCloud capture feature on iOS, but because I don’t use Siri on a daily basis, that didn’t turn into a habit. I know many rely on OmniFocus-Reminders integration, and I think these are nice solutions for the desktop.

I, however, have become a big fan of The Omni Group’s Mail Drop service. Using Drafts, I can write down a task, send it to Mail Drop, and have it in my OmniFocus inbox after a few minutes; if I want to save a link to a webpage, I can use a bookmarklet that sends a website to Drafts and then to Mail Drop. Rather than further integrating OmniFocus and Reminders, I’d like to open OmniFocus on iOS and find it already synced with all other copies of the app and Mail Drop. Right now developers have to resort to location-tricks to update information in the background, and I wish Apple will allow more background options in the future.


Evernote Image Extractor

Evernote Image Extractor

Nice AppleScript by Chris Sauve:

A recurring knock against Evernote has been its poor exportability. The best option for moving my library would have been to export the Evernote notes as HTML, but any images that were captured using Evernote’s web clipper come out with inscrutable names, each of which would have to be changed manually. So, I did what I have been doing lately: I built an Applescript.

Evernote is often criticized for its exporting options, but the app has been improved from this standpoint in the past major updates. For instance, I like how you can select multiple notes containing attachments and save them to a folder in the Finder. More importantly, I like how Evernote keeps supporting AppleScript and how they’re still introducing more scripting features (it happens rarely these days). Chris’ AppleScript is a great example: it offers a simple interface to pick a notebook containing notes with images, and it’ll export those images using the filename of their respective notes – not the name of the image files.

Go download it here.


Launch Chrome Bookmarklets With Keyboard Shortcuts

A few weeks ago I switched back from Safari to Google Chrome. I wanted to give Safari a fair chance, especially after the introduction of iCloud Tabs, but, alas, the browser never “clicked” for me the way Chrome did. Worse, using Safari on a daily basis for work-related tasks became an unsafe bet, as it was crashing too often, taking several minutes to sync my iCloud Tabs, or generally hanging for no apparent reason. I’m still figuring out the ins and outs of Chrome – particularly how to handle the lack of a “default browser” option on iOS – but, so far, Chrome is working better for me.

One thing I miss from Safari is the ability to launch bookmarks in the Bookmarks Bar with a simple CMD+1…9 keyboard shortcut. I use a lot of bookmarklets (which, by the way, Chrome syncs faster than Safari across devices), and I’m too used to hitting CMD+2 for OmniFocus and CMD+4 for Pinboard to give up the convenience of quick bookmarklet activation. Unfortunately, Chrome uses Safari’s CMD-based shortcuts for switching between open tabs.

The solution was laying in my dock the whole time. As cleverly shown by Patrick Welker, you can use a Keyboard Maestro macro to assign a keyboard shortcut to what is, essentially, Keyboard Maestro’s own GUI scripting, only done with a visual workflow. Make sure to read Patrick’s post to see how you can create a simple macro to “click” a bookmark in Google Chrome.

For the non-Keyboard Maestro users, a solution is to actually use AppleScript GUI scripting to simulate clicking a bookmark’s name. Using something like the script below, you can use any launcher that supports assigning a keyboard shortcut to an AppleScript to quickly launch a Google Chrome bookmark.

tell application "System Events"
	tell process "Google Chrome"
		click menu item "pin" of menu "Bookmarks" of menu bar 1
	end tell
end tell

The script could use an error-checking system to see if Chrome is the frontmost application, but I avoided adding it because I know I won’t use the shortcut anywhere else.

As for Chrome on iOS: because the browser forces you to type out bookmarklet names to launch them, my suggestion is to use a standard prefix so you’ll be able to launch them easily from the iOS keyboard. For instance, I prepend “xx” to my most used bookmarklets, so Chrome for iOS will filter the names right away.

Gruber On AppleScript

Gruber On AppleScript

John Gruber, in an AppleScript retrospective for Macworld:

To recap: Decidedly old-school-Apple/pre-NeXT technology. A programming language syntax that frustrated experts and failed to achieve its intended goal of empowering non-programmers to program. A technical mismatch with the Cocoa application framework. You need this historical context to understand how unlikely AppleScript’s long-term success was. Someone with access to a time machine could make a lot of money by going back to Apple’s Worldwide Developers Conference 1998 and accepting wagers that AppleScript would be alive and well in the year 2012.

But alive and well it is.

Just last night I tweeted that, while Apple may still support AppleScript, it doesn’t look like it holds a spot in the list of “top priorities” for Mac OS software. And that makes perfect sense, as the company has been focusing on other areas for the past few years: removing cruft and bringing consistency across its desktop and mobile devices.

The fact that AppleScript still works on Mountain Lion after the Gatekeeper and Sandboxing changes is, alone, quite remarkable. But there’s no denying that “supporting AppleScript” isn’t generally regarded as a feature that needs to be in version 1.0 of an app. Apple itself supports only one command for Reading List – a major feature of Safari 5 – a whole year after its introduction. Of all the new third-party apps I’ve tried in the past year, only a very few of them support AppleScript: Rdio, Fantastical, PopClip. And then again, they don’t have extensive AppleScript dictionaries. On the other hand, apps that already supported AppleScript continue to offer that kind of integration: I think of The Omni Group’s apps, Evernote, PDFpen, BBEdit, or Acorn as notable examples.

You may argue that “supporting AppleScript” was never in the list of features a Mac developer had to support when shipping version 1.0 of an app. That’s probably true, but, again, my point is different.

The OS X landscape has changed. In the past two years – especially after the release of the iPad – developers have prioritized cloud sync, consistency, and gestures over inter-app communication and scripting. Those have to be priorities because those qualities have created a stronger ecosystems for everyone. When it comes to scripting and inter-app communication, you know where I stand. I don’t know if AppleScript will ever be a “priority”, because maybe it really isn’t meant to be one.

Like Gruber, I’m just glad it’s still around. In fact, I look forward to finally releasing a little AppleScript project I’ve been working on since September.


From Instapaper and Pythonista To Dropbox and Evernote As PDF

I’ve already expressed my preference for archiving webpages as PDFs rather than simple “bookmarks” on an online service. When I come across a webpage that I know I want to keep for future reference, I like to generate a clean-looking PDF file with selectable text that I can rely on for years to come.

Lately, I have become obsessed with turning longer articles I find on the Internet also into PDFs for long-term archival. For as much as I like Instapaper, I can’t be sure that the service will be around in the next decades, and I don’t want my archive of longform and quality content to be lost in the cloud. So I have come up with a way to combine Instapaper with the benefit of PDFs, Dropbox, and automation to generate documents off any link or webpage, from any device, within seconds.

Yesterday I put together an iOS and OS X workflow to generate PDFs remotely on my Mac, starting from a simple bookmarklet on iOS. On an iPhone or iPad, I can simply hit a button in Safari, and wait for Pythonista to turn a webpage (that’s already been passed through Instapaper’s text bookmarklet) into an .html file in my Dropbox, which is then converted to PDF and added to Evernote. It sounds complex, but in actual practice I can go from a Safari webpage on iOS to a PDF in the Evernote app in around 30 seconds. Hopefully you’ll find this quick solution useful; feel free to modify it and/or send suggestions. Read more

The Unarchiver AppleScript, iOS App, and Archive Browser

I have been using The Unarchiver for years now. It’s been listed in my Must-Have Mac Apps roundups, and I recommend it to every friend who, after switching from Windows to OS X, asks me about “WinRAR for Mac”. The Unarchiver is a powerful and simple extraction tool with support for multiple formats and a set of user preferences to configure in the Settings.

There have been some updates to The Unarchiver lately. The free Mac app, The Unarchiver, received initial AppleScript support with a dictionary that supports extraction and various options such as location of extracted files and originals. Whilst The Unarchiver is pretty straightforward in itself, AppleScript support means you’ll be able to put together automated workflows with loops, if conditions, and different settings than the app’s ones. More importantly, you’ll be able to extend The Unarchiver and make it communicate with other apps installed on your Mac (an example: automate downloads with Transmit and extract with The Unarchiver in AppleScript). Here’s a sample extraction script for the file currently selected in Finder:

tell application "Finder"
	set sel to the selection as text
	set the_file to POSIX path of sel
	tell application "The Unarchiver"
		if isRunningExtractions is false then
			unarchive the_file to Original with deleting Original
		end if
	end tell
end tell

Developer Dag Agren has also released a paid iOS app for The Unarchiver. Initially buggy, Dag has been busy improving it and making it more reliable on iOS 6. Called Archives, it is based on The Unarchiver, which means you’ll get support for a plethora of formats. The app lets you look inside archives and preview files before extracting them; you can open a file in other apps that support the format using Open In, you can save images to the Camera Roll, and check out advanced information for each file. I have found Archives to be particularly useful in previewing files from Mail or Safari. Archives is $1.99 on the App Store.

Last, inspired by Archives for iOS, Archive Browser for OS X is a paid version of The Unarchiver with support for browsing and previews before extraction. It supports Quick Look, and it’s $3.99 on the App Store.

PopClip Extensions

PopClip Extensions

I first wrote about PopClip last year. Developed by Pilotmoon, it is a simple utility that brings an iOS-like popup menu for text selected on OS X. From my original coverage:

PopClip, a $4.99 app from the Mac App Store, takes a page from iOS’ playbook and overhauls the Mac’s default copy and paste actions with an iOS-like popup menu.

With PopClip, you can select text and a popup menu with options to copy, paste, cut and look up in Dictionary will appear, just like on your iPhone or iPad. PopClip is also capable of opening links contained in selected text, and it’s got support for spelling corrections.

I recently found out (thanks to a Systematic episode) that it’s possible to extend PopClip. Version 1.4, in fact, brought support for extensions. Pilotmoon has posted a dedicated page showcasing some examples of extensions already available. The best part? PopClip extensions can be made with AppleScript, shell scripts, system Services – it’s very easy to adapt existing scripts to PopClip’s syntax for selected text (literally one word). Extensions can have custom icons, names, and requirements, and to put one together you’ll need to create a .plist file for the extension’s settings. For developers, Pilotmoon has also posted instructions on how to create and package extensions.

Personally, I have already installed some of the extensions linked on PopClip’s page (such as Evernote, Title Case, and Paste and Match Style), as well as an OmniFocus one by Marc Abramowitz and a set by Andy Guzman. To prove it’s really simple to update existing scripts for PopClip, I’ve created a version of today’s Mail > Evernote AppleScript that works for text selected with PopClip in an email message; it’s very simple, but you can find it here.

I’m looking forward to seeing more people playing around with PopClip extensions. It is an interesting combination, as these extensions mix the power of scripting with the visual aspect of “seeing” commands, rather than remembering dozens of keyboard shortcuts. In a way, it reminds of a Services menu for iOS, which I hope we’ll get, eventually.

PopClip is $4.99 on the Mac App Store.