Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Media files and applescript


This topic is 6266 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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" ?

Posted

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..

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.