• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
10

InDesign scripting - OSAscript Activate finder

Enthusiast ,
Nov 26, 2023 Nov 26, 2023

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.

TOPICS
Scripting

Views

113

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 26, 2023 Nov 26, 2023

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 26, 2023 Nov 26, 2023

Copy link to clipboard

Copied

LATEST

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 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines