Wednesday, October 28, 2015

When Open Does Not Return an Object Reference

Mark Alldritt:

The code below shows one way of working around the problem of the Open command not returning a reference to the newly opened document. I use the Preview application in my code, but this technique works equally well with other application which fail to return a document reference from their Open commands. This technique fails if the file is already open.

One of the main frustrations with AppleScript is that sometimes things like this that should be easy end up requiring a big chunk of copy and pasted code.

1 Comment RSS · Twitter

The flipside is that if application developers cared enough about the quality of their automation support, they could've created their own reusable Apple event server framework, thereby avoiding the third-rate clunker that is Cocoa Scripting completely.

But with few automation-using customers and not being enthusiastic users of automation themselves - in both cases because the only competent AE client is AppleScript (which sucks in all other respects) - it simply isn't worth their time to do so.

How sad that Mac Automation is often not so much about solving users' problems as working around damage (including Mac Automation itself). It's certainly not how it should be.

Leave a Comment