Skip to main content
Inspiring
May 25, 2024
Answered

error: passing value from apple script to javascript

  • May 25, 2024
  • 1 reply
  • 271 views

I can use similar logic to passing value with illustrator, but PS occur an error. why ?
There is no problem with the file path. Is it related to security permissions?
also,  Software Menu---File----scripts----browse, then I can't select .scpt format file, it is strange.
result:
error "Adobe Photoshop 2024 got an error: Can’t get file \"Macintosh HD:Users:c144:Desktop:thScript:CovertBMP.jsx\"." number -1728 from file "Macintosh HD:Users:c144:Desktop:thScript:CovertBMP.jsx"


applescript:
set userName to short user name of (system info)
set baseFolderPath to "/Users/" & userName & "/Desktop/thScript/"
set scriptFileName to "CovertBMP.jsx"
set scriptPath to baseFolderPath & scriptFileName as POSIX file
set nameParameter to {"1887-9-01.eps", "1887-9-(1).bmp", "600", "/Users/c144/Desktop/thScript/"}
set argumentsList to {nameParameter}
tell application "Adobe Photoshop 2024"
activate
do javascript scriptPath with arguments argumentsList
end tell

javascript:
#target Photoshop
var arr = [];
function main(dataIn) {
var value1 = dataIn[0];
var value2 = dataIn[1];
var value3 = dataIn[2];
var value4 = dataIn[3];
arr.push(value1);
arr.push(value2);
arr.push(value3);
arr.push(value4);
}
main(arguments[0]);
var epsName = arr[0] ;
var bmpName = arr[1];
var pixels = arr[2];
var folderPath = arr[3];

This topic has been closed for replies.
Correct answer rui huang

code should use "do javascript of file scriptPath with arguments argumentsList"

1 reply

rui huangAuthorCorrect answer
Inspiring
May 27, 2024

code should use "do javascript of file scriptPath with arguments argumentsList"