z178 Posted September 27, 2007 Posted September 27, 2007 A database I have has media added with "Store as a reference" checked. How can I create a button which when clicked would launch the file and perform an applescript. In other words, upon clicking the button, if the file opens in "Preview.app", Can I use the perform applescript script step to script "Preview.app" ?
Fenton Posted September 27, 2007 Posted September 27, 2007 Well, you can certainly use Perform AppleScript to run an AppleScript, and you can attach it to a button. And it can open a file with a specific application. You will run into a small glitch if you try an AppleScript Preview.app, as it is not AppleScript, out of the box. This should be embarrassing to Apple, but for some reason it is not. Often Preview is the default app for images files on a Mac, unless you've changed that. So telling the Finder to open an image file will open it in Preview, same for print. It is also possible to turn on basic AppleScript capability for Preview, by running a simple command line. I saw this tip by Sal Soghoian, so you can rely on its safety. The first line will read your (user) current AppleScript capability of Preview (likely null). Uncomment and run the 2nd line to turn on basic AppleScript for Preview, for the current user. (Sal's command was for the main Library, but that didn't seem to work for me, and I'm content to do it for just me.) do shell script "defaults read com.apple.Preview NSAppleScriptEnabled" -- do shell script "defaults write com.apple.Preview NSAppleScriptEnabled -bool YES" You don't get much, but you can do simple things like tell Preview to open a file, print it, get the name of document 1, etc..
Recommended Posts
This topic is 6266 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now