parameter pass from applescript to javascript
Could you please anyone share the codes for pass the arguments from applescript to external javascript
Could you please anyone share the codes for pass the arguments from applescript to external javascript
Hi raghav, Try follwing sample
Apple script
set jsFilePath to "~/Desktop/sample1.jsx"
set customArguments to "Hello"
set _name to "Test User"
with timeout of 620 seconds
tell application "Adobe Illustrator"
activate
do javascript file jsFilePath with arguments {customArguments, _name}
end tell
end timeout
Javascript
try {
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
if (arguments.length > 0) {
main(arguments);
} else {
alert("No arguments were found.");
}
} catch (e) {
alert("Manual Run");
main();
}
function main(args) {
if (typeof (args) != "undefined") {
var message = args[0] + " " + args[1];
alert(message + " in Illustrator");
}
}
The above code will launch Illustrator and display arguments on alert. This code is only to show interaction. To run this just run the applescript code, it will automatically open Illustrator if not open already.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.