This week's sponsor

Remote for Mac

Turn iPhone or iPad into remote control for your Mac


Posts tagged with "applescript"

Enhancing Reminders with AppleScript and Macros

As The Omni Group keeps working on OmniFocus 2 for Mac and Apple continues seeding new betas of iOS 7 and OS X Mavericks to developers, I have been reconsidering Reminders’ simplicity and enjoying the built-in iCloud sync, which, unlike other types of iCloud, is working fine for me. However, two things I miss from OmniFocus are the possibility to integrate the app with a web browser through bookmarklets and the system-wide Quick Entry panel; I use both tools on a daily basis to easily save a browser’s tab into OmniFocus’ Inbox, or to bring up a text field where I can jot down an idea and know that, no matter the app I’m using, it’ll be saved into OmniFocus. Luckily for me, Apple’s Reminders app comes with a good AppleScript Dictionary, which is likely something that Reminders’ core mainstream audience won’t ever care about, but that we can leverage to extend the app’s capabilities and input areas beyond Mountain Lion’s leather-and-paper window.

Read more


Automating Mail Signatures and Senders with AppleScript and Keyboard Maestro

Mail Keyboard Maestro

Mail Keyboard Maestro

I’m aware of the fact that it’s a common trend to call email a “nightmare” these days, but the truth is – email works for me. I have multiple addresses set up, I have my filters and smart folders to automate the process of filing and finding emails, and I’m enjoying the renewed interest of iOS developers in building email apps that solve old problems in new ways. But there is one thing I don’t like: Apple’s Mail app and how many clicks it takes to switch between configured accounts and signatures. As you can guess, I came up with a way to automate the process using AppleScript and (optionally) Keyboard Maestro.

I receive several messages every day to different email addresses, but I always want to reply with the same address and the same signature. Apple’s Mail app makes it easy to see all messages sent to all accounts with the unified Inbox, but it makes it surprisingly hard to set default accounts and signatures that should always be treated as, well, default ones. I don’t want to click on menus for accounts and signatures: I want to hit ⌘R and receive a new Reply window with the account and signature I want already set. Read more


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.

Permalink

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.

Permalink

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.

Permalink

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