Is OSX Lion (or older OSX) release of Preview scriptable?
-
5ah, ah, it is not a real question but I got real answers. many people with not enough knowledge have big egos here. like wikipedia, decline is easily envisionable if policies do not change very soon. – P5music Dec 12 '11 at 18:05
-
1NSAppleScriptEnabled is set to true in Preview's Info.plist in 10.9, so Preview has a basic AppleScript dictionary by default. There is still no real AppleScript support though. – Lri Nov 18 '13 at 18:07
3 Answers
Preview is not now, and have never been AppleScript-able, which does suck. It'd be nice if it were, though.
From this blog:
However, from 10.4–10.6 it was possible to enable the default Cocoa scripting support via these Terminal commands:
sudo defaults write /Applications/Preview.app/Contents/Info
NSAppleScriptEnabled -bool YES
sudo chmod a+r /Applications/Preview.app/Contents/Info.plist
This was sufficient to be able to get at the file of the current document to delete it, change its Finder label, import it into EagleFiler, etc. Under 10.7, modifying the Info.plist file breaks the application’s code signature. I would expect this to cause a harmless warning message in the Console, but it actually causes Preview to crash.

- 1
- 1

- 22,308
- 13
- 63
- 94
-
2I've posted some instructions for making Preview scriptable on Mac OS X 10.7: http://c-command.com/blog/2009/12/28/capture-from-preview/ – Michael Tsai Dec 19 '11 at 01:51
If you want to find out if Preview (or any other application) is Applescriptable, then just try File > Open Dictionary in Script Editor.
This is described in Apple's documentation here.

- 5,328
- 22
- 35
If you really need to script it, you could always use GUI scripting. This method allows you to script any application, although it can be ugly and tedious to get it to work. Only use as a last resort.
You can find more information here : http://www.macosxautomation.com/applescript/uiscripting/index.html

- 4,773
- 1
- 25
- 52