Indesign javascript parameter pass to Apple Script

Participant ,
Aug 01, 2020 Aug 01, 2020

Copy link to clipboard

Copied

Hi Everyone,

Applescript +javascript integration!!!!!

Is this is possible to pass the javascript parameter to apple script.

For example I need to find the missing links indesign files using javascript and the return the value will reflect in the apple script as a alert.

 

TOPICS
Scripting

Views

186

Likes

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
Guru ,
Aug 01, 2020 Aug 01, 2020

Copy link to clipboard

Copied

Yes, you can do it sending parameters via withArguments parameter using the application's doScript method.

Here's some interesting info about it and here is a script that uses this approach (see the arguments file section).

Though I don't understand why you prefer AppleScript's display dialog instead of JavaScript's alert().

Likes

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
Participant ,
Aug 02, 2020 Aug 02, 2020

Copy link to clipboard

Copied

Thankyou Kas!

Orignally, the code was developed with apple script and it was developed to pass the arguments to javascript to perform some dynamic functionalities. Adding some information, I need to pass the arugment to apple scriptfor performed action in JS

Likes

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
Adobe Community Professional ,
Aug 02, 2020 Aug 02, 2020

Copy link to clipboard

Copied

I didn’t go through all of Kas’s links—sorry if this is covered— here is an Applescript example that sends two arguments to a Javascript saved to the desktop, and runs the JS:

 

 

 

 

 

 

--AppleScript

tell application "Adobe InDesign 2020"
	activate
	--path to Javascript to receive arguments
	set JS to "...Desktop:MyJSScript.jsx"
	set a to "Foo"
	set b to "Bar"
	set args to {a, b}
	do script JS language javascript with arguments args
end tell

 

 

 

 

 

 

The receiving MyJSScript.jsx

 

 

 

var a1 = arguments[0];
var a2 = arguments[1];
alert("From JavaScript, arguments: " + a1 + "  & " + a2 + " received.");

 

 

 

 

 

 

Likes

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
Participant ,
Aug 19, 2020 Aug 19, 2020

Copy link to clipboard

Copied

Objective: return the value from javascript to apple script

 

Is this possible to return the value to apple script and display as a alert.

 

My requirement is some function wrote in javascript for example, If I wrote the function for overset text found, the overset is found in the script it need to alert the overset in apple script display alert. 

Likes

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
Participant ,
Aug 19, 2020 Aug 19, 2020

Copy link to clipboard

Copied

"From JavaScript, arguments: " + a1 + "  & " + a2 + " received."

 

This should value should return to apple script and display alert in apple script.

Likes

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
Adobe Community Professional ,
Aug 19, 2020 Aug 19, 2020

Copy link to clipboard

Copied

LATEST

I don’t see any way to add an AppleScript listener to the JS script, so even a JS function with a return value would not get returned to the AS script. You might be able to write a text file with the return value, and have the AS script open, and get the value, but it would have to wait for the text to be written.

 

So why aren’t you checking for the overset text with an AppleScript handler?

Likes

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