AppleScript and Preview.app

0

I saw this post:

How do I get applescript to work with Preview in Snow Leopard?

In my attempt to figure out how to use AppleScript with Preview. I'm trying to automate a series of tasks that will open documents and resize them automatically to the most efficient view in situations where I need to view multiple documents at once. I can't figure out how to add scripting functionality in Preview (meaning simply, I can't get Automator or AppleScript to resize preview windows automatically). I saw this thread but there was no answer. I'm wondering if you've figured anything out since then.

Jared

Posted 2010-07-12T22:27:34.077

Reputation: 1

Answers

2

In Mac OS Lion the Info.plist owns you:

sudo defaults write /Applications/Preview.app/Contents/Info NSAppleScriptEnabled -bool true
sudo chmod 644 /Applications/Preview.app/Contents/Info.plist
sudo codesign -f -s - /Applications/Preview.app

Now this shouldn't cause an error:

tell app "Preview" to windows

As in 10.6, Preview still won't have a dictionary.

Lri

Posted 2010-07-12T22:27:34.077

Reputation: 34 501

1

My answer to that post you mention has a link to this macscripter.net thread which shows a terminal command (defaults write /Applications/Preview.app/Contents/Info NSAppleScriptEnabled -bool YES) that turns on basic scripting for Preview.

One of the links on that thread is to this red-sweater.com blog post, which explains in depth how to resize document windows in Preview.

So I guess I had answered that question. :)

ghoppe

Posted 2010-07-12T22:27:34.077

Reputation: 6 124

WARNING: Don't follow ghoppe's suggestion above for the Lion (10.7) version of Preview. Changing anything inside of the application's executable will invalidate the code signing check and cause Preview not to open. Worse, it's really difficult to get the Preview application working again without access to another system running Lion -- you can't just "undo" the property list edit to roll back to a working version! – None – 2011-08-04T23:06:45.533