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.,
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/
...
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:
Copy link to clipboard
Copied
Dear rob day
Thank you for your Kind support. it is working fine.
Thanks & Regards,
Harihara sudhan T R.,