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

how to run applescript ".scpt" file from JavaScript / UXP

Explorer ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

Hi All,

 

We already developed a Apple Script, which will open the file into HTML Web page. need to run that Apple Script ".scpt" file from InDesign Javascript. Kindly help me, I will  appriciate. 

 

Thanks & Regards

Harihara Sudhan T R.,

TOPICS
Scripting , UXP Scripting

Views

319

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

correct answers 1 Correct answer

Community Expert , Aug 02, 2023 Aug 02, 2023

Hi @Harihara28692478zxj6 , If the AppleScript is complex you could save it as a text file from script editor (Script Editor  saves Text formated files wth the .applescript extension) then load it into your Javascript and call app.doScript(). For example this applescript saved as text to my desktop:

 

 

 

tell application id "com.adobe.indesign"
	activate
	set d to active document
	display dialog "Active Document: " & name of d
end tell

 

 

 

Called in this JS:

 

 

 

var as = readFile("~/Desktop/
...

Votes

Translate

Translate
Community Expert ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

Hi @Harihara28692478zxj6 , If the AppleScript is complex you could save it as a text file from script editor (Script Editor  saves Text formated files wth the .applescript extension) then load it into your Javascript and call app.doScript(). For example this applescript saved as text to my desktop:

 

 

 

tell application id "com.adobe.indesign"
	activate
	set d to active document
	display dialog "Active Document: " & name of d
end tell

 

 

 

Called in this JS:

 

 

 

var as = readFile("~/Desktop/ASExample.applescript")

$.writeln(as)
/* returns
tell application id "com.adobe.indesign"
	activate
	set d to active document
	display dialog "Active Document: " & name of d
end tell */


app.doScript(as, ScriptLanguage.applescriptLanguage);

/**
* Read a text file 
* @ param p the path to the text file 
* @ return the file‘s text 
*/

function readFile(p) {
	var f = new File(p);
	f.open("r");  
	var x = f.read(); 
	f.close();
	return x; //returns the text in the file sampletext.txt
}

 

 

 

The result in InDesign:

Screen Shot 18.png

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
Explorer ,
Aug 03, 2023 Aug 03, 2023

Copy link to clipboard

Copied

LATEST

Dear rob day

 

Thank you for your Kind support. it is working fine.

 

Thanks & Regards,

Harihara sudhan T R.,

 

 

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