Copy link to clipboard
Copied
I'm trying to activate finder with osascript, this command works directly in terminal, but will not work when called through doScript.
Works in terminal:
osascript -e 'tell application \"finder\" to activate
Causes error being called through InDesign
app.doScript("osascript -e 'tell application \"finder\" to activate", ScriptLanguage.applescriptLanguage);
Here is the error:
Eval Error (#-2740): "A unknown token can’t go after this identifier." in '/Users/PATH TO SCRIPT/script.jsx' [6:undefined] in host 'indesign-19.064 (main)'.
This alternative seems to work:
app.doScript('do shell script "open -a finder"', ScriptLanguage.applescriptLanguage)
Right before this, I run a function that opens a finder window, then I launch an alert through indesign so it steals focus, and I want to activate finder as the last step. Is there a way with OSA script? Just wondering if it's possible in case I needed to run additional steps.
Copy link to clipboard
Copied
app.doScript("osascript -e 'tell application \"finder\" to activate", ScriptLanguage.applescriptLanguage);
It doesn't work because it's not AppleScript - it's shell script.
You just need to leave the AppleScript portion: 'tell app \"Finder"\ to activate'
Anyway, you mentioned that your last shell script does work. So I assume you do have a solution?
Copy link to clipboard
Copied
One approach to "activating the Finder" is to call the "execute" method of a Folder object, so:
var scriptFolder = $.fileName.parent; // this is the Folder containing the active script file
// activate the Finder by "revealing" the folder
scriptFolder.execute();
I find this really handy after exporting files, for example.
- Mark