问题
Is OSX Lion (or older OSX) release of Preview scriptable?
回答1:
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.
回答2:
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.
回答3:
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
来源:https://stackoverflow.com/questions/8474657/is-osx-lion-preview-application-scriptable