Copy link to clipboard
Copied
Hi, I need to call photoshop js from applescript. Here what I have so far:
tell application "Adobe Photoshop CS4"
activate
set myScript to "Applications:Adobe Photoshop CS4:Presets:Scripts:_NDF_Ph_saveAsTif.jsx"
do javascript (myScript)
end tell
and it's compiles, but when runs, gives me "Error 25: Expected: ;." message.
How can I call ps script from as.
Thank you very much for your help.
Yulia
Copy link to clipboard
Copied
You have 2 ways either JavaScript supplied as string or as file. If you are going the route of file then you need to coerce your path string to 'alias' this will fail if it does NOT exist. Here are 2 examples. You also have option to pass arguments as list.
-- As String
set JavaScript to "myTest();
function myTest() {
var docRef = app.activeDocument;
var docWidth = docRef.width;
var docHeight = docRef.height;
var docSize = docWidth + ' x ' + docHeight
return docSize
}"
tell application "Adobe Photoshop CS2"
activate
set Doc_Ref to the current document
tell Doc_Ref
do javascript JavaScript ¬
show debugger on runtime error
display dialog the result
end tell
end tell
-- As File
set ScriptPath to (path to applications folder as text) & "Adobe Photoshop CS2:Presets:Scripts:Hello.jsx" as alias
tell application "Adobe Photoshop CS2"
activate
set Doc_Ref to the current document
tell Doc_Ref
do javascript ScriptPath ¬
show debugger on runtime error
end tell
end tell
Copy link to clipboard
Copied
This is great. I tried the alias one and it works, and I am sure I will be able to use the other one at some point.
Thank you, Mark.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now