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

Sample script from Adobe with app.doScript does not work

Community Beginner ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

Hello,

I am trying to get a script to work that was provided by Adobe themselves.

var myParameters = ["Hello from DoScript", "Your message here."];
var myJavaScript = "alert(\"First argument: \" + arguments[0] + \" \\rSecond argument: \" + arguments[1]);";
app.doScript(myJavaScript, ScriptLanguage.javascript, myParameters);

if(File.fs == "Windows"){
    var myVBScript = "msgbox arguments(1), vbOKOnly, \"First argument: \" &  arguments(0)";
    app.doScript(myVBScript, ScriptLanguage.visualBasic, myParameters);
    }
else{
    var myAppleScript = "tell application \"Adobe InDesign CS6\\rdisplay dialog(\"First argument\" & item 1 of arguments & return & \"Second argument: \" & item 2 of arguments & return & end tell";
    app.doScript(myAppleScript, ScriptLanguage.applescriptLanguage, myParameters);
}

I get the error message 

app.doScript is no function

I admit, I am starting to use Indesigns ExtendScript Toolkit. So I have to work into it. 
However, this is from here (page 16):

https://www.adobe.com/content/dam/acom/en/devnet/indesign/sdk/cs6/scripting/InDesign_ScriptingGuide_...

Could perhaps s.b. corrcect it so it runs?

Thank you

Andi

 

TOPICS
Scripting

Views

973

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 ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

Hi Andi,

Did you choose the InDesign application from the top-left dropdown in Extendscript Toolkit before executing the script? Let us know which version of InDesign you are using, which OS etc.

A screenshot of your script execution and error would be helpful I suppose.

-Manan

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 ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

app.doScript is no function

 

Also, the script is also looking for InDesign CS6, so unless you alter the code you’ll need to target CS6:

 

Screen Shot 30.png

 

If you are on a Mac the provided string for the myAppleScript variable will throw an error. It needs to be something like this:

 

 

    var myAppleScript = "tell application \"Adobe InDesign CS6\"\rdisplay dialog \"First argument: \" & item 1 of arguments & return & \"Second argument: \"& item 2 of arguments\rend tell";

 

 

If you want to target CC2020 is would be this:

 

 

    var myAppleScript = "tell application \"Adobe InDesign 2020\"\rdisplay dialog \"First argument: \" & item 1 of arguments & return & \"Second argument: \"& item 2 of arguments\rend tell";

 

 

 

Also, if you are just starting with scripting, I don’t see how calling AppleScripts or Visual Basic scripts would be very useful. JavaScript is already cross platform. Writing and calling matching AS and VB scripts from InDesign would be really challenging. If you want to communicate between Adobe apps it can be done with BridgeTalk

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
Guide ,
Apr 13, 2021 Apr 13, 2021

Copy link to clipboard

Copied

LATEST

As @rob day already wrote you you have to address InDesign via the target dropdown of ESTK.

 

I still think there are use cases for the platform script languages as soon you have to reach out to other program. For example a script could fill in a QR code from the selected entry of Contacts.app .

 

To avoid version specific application names, you can also address the application by its bundle id.

The following is a single line script, I enclosed it in single quotes instead of escaping the contained double quotes.

 

var myAppleScript = 'tell application id "com.adobe.indesign" to get version';

 

 

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 ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Hi Andi,

some annotations:

[1] The first app.doScript() should work on Mac OS X and Windows 10 as well, if the ESTK is connected to a version of InDesign later than CS3, I think.

[2] The second app.doScript() could run into an error on Windows 10 as I tested with e.g. InDesign 2021. It should work with InDesign CS6 (as it did) on my machine. Why this is not working for me, the code that is in variable myVBScript, is unclear to me. The error message with InDesign 2021 on my German Windows 10 system is (translated to English): "Adobe InDesign 2021 Type Library cannot be loaded (Version 1.0)"

 

As I already said:

Executing variable myVBScript through app.doScript() with my German InDesign CS6 version 8.1.0 is no issue.

 

Regards,
Uwe Laubender

( ACP )

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 ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Hi Uwe, I get an error with @andreasm17830516 ’s script on OSX—Expected end of line but found "first".

 

You can see the problem if you get myAppleScript.toString(), which returns an AS that would not compile in AppleScript:

 

 

 

var myAppleScript = "tell application \"Adobe InDesign CS6\\rdisplay dialog \"First argument\" & item 1 of arguments & return & \"Second argument: \" & item 2 of arguments & return & end tell";

$.writeln(myAppleScript.toString())
    
//AS returned
//tell application "Adobe InDesign CS6\rdisplay dialog("First 
//argument" & item 1 of arguments & return & "Second 
//argument: " & item 2 of arguments & return & end tell

 

 

 

AppleScript doesn’t use parenthesis for method calls so display dialog() doesn’t work. This does:

 

 

 

var myAppleScript = "tell application \"Adobe InDesign 2020\"\rdisplay dialog \"First argument: \" & item 1 of arguments & return & \"Second argument: \"& item 2 of arguments\rend tell";

$.writeln( myAppleScript.toString());

// AS returned:
// tell application "Adobe InDesign 2020"
// display dialog "First argument: " & item 1 of arguments & return & "Second argument: "& item 2 of arguments
// end tell

 

 

 

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