Copy link to clipboard
Copied
Hi everyone,
I was looking for a way to execute AS from JS to bind my AS on hotkey.
I found a thread with this code in there:
// JavaScript
var myscr = new File('/C/1/book/my.vbs');
if (myscr.exists) {
app.doScript(myscr, ScriptLanguage.visualBasic)
}
do I thought that I'll create a .jsx file with this code and it'll work
var myscr = new File('/Users/macintosh/Documents/Adobe Scripts/enter.applescript'); if (myscr.exists) { app.doScript(myscr, applescriptLanguage) }
but it didn't
I fought that the problem is that doScript is from inDesign/Illustrator and tried doAction but it seems it's only for Actions.
Please explain me what am I doing wrong?
Kind regards, Sergey
Copy link to clipboard
Copied
Try
myscr.execute()
Copy link to clipboard
Copied
Hi Tom, thanks for answer. It seems however that execute() launches AppleScript Editor instead of launching the script, similar for double click the file.
My research in Extendscript Editor dictionary showed that PS simply doesn't have doScript function InDesign has. This sucks.
Copy link to clipboard
Copied
Take a look at the documentation each of Adobe's apps differs in its scripted commands. ID has 'do script' in given language (the best of the bunch) Photoshop will let AppleScript & Visual Basic do JavaScript. Illustrator is like Photoshop except you can pass an arguments array to the command…
File.execute(); did NOT work with my quick test the calling JavaScript:
#target photoshop var appleScript = new File('~/Desktop/Test.app'); if (appleScript.exists) appleScript.execute();
The AppleScript compiled and saved as 'Application' in on run statement…
on run
tell application "Adobe Photoshop CS2"
activate
if exists document 1 then
set Doc_Ref to current document
tell Doc_Ref
set Doc_Name to name
display alert "Testing" message ¬
Doc_Name giving up after 2
end tell
else
display alert "Script Error" message ¬
"No document is open." as warning giving up after 2
end if
end tell
end run