Copy link to clipboard
Copied
Hello,
I am new to applescript and was wondering if there is a way to execute the Image Processor javascript via applescript.Image Processor is a javascript where you need to press the Run button in order to execute it. The current code I have doesn't do the trick:
tell application "Adobe Photoshop CC 2019"
activate
do javascript (file "Macintosh HD:Applications:Adobe Photoshop CC 2019:Presets:Scripts:Image Processor.jsx")
delay 10
tell application "System Events" to click at {1550, 450}
end tell
I had a look at the following post but it didn't fully answer my question.
Copy link to clipboard
Copied
If I'm right 'do javascript' is not Photoshop, but Illustrator specific.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
That's right, I forgot it's special command for Apple Script.
Copy link to clipboard
Copied
Try here, inline code works fine, but an external reference does not:
Request: Add Scale Styles option to "resize image" command in AppleScript
Copy link to clipboard
Copied
Unfortunately the do Javascript code keeps executing until you press the return or esc key on the keyboard.
Only then will the do Javascript code finish and the line for the system events execute.
Copy link to clipboard
Copied
The Image Processor Script is not a Photoshop Plug-in. The Image Proessor's interactive Dialog can not be bypassed like Plug-in dialogs can be by Action step using the plug-in or the script using the plug-in which pass the settings for the Plug-in dialog recorder into the Action step by the plug-in when the Actions was recorder, or the Script passing the Plug-in the settings for its dialog. The plug-in will bypass displaying its Dialog when the setting are pass. I do not know anything about Apple or what your code after calling Image processor is for
"
delay 10
tell application "System Events" to click at {1550, 450}
"
That code would not execute till after the image processor script finish running. I hope that System event click at 1550, 450 is not intended to click on the Image processor dialog run button.
The Image Processor Pro... is a Photoshop Plug-in script its dialog can be bypassed when you call it you can pass the dialog settings you want it to use. It has a quite complex dialog. It may be easier to record using the Image Processor Pro in an actions and let Image Processor Pro... record the settings you use in its dialog recording the action step. Then have your applet script run your action that has the step menu File>Automate>Image Processor Pro... .
The Image Processor... script uses Adope Plug-in Fit Image which is a Plug-in script here is the code from Image Processor script to call Fit Omage and bypass the Fit Image dialog. It uses action manager code
// use the fit image automation plug-in to do this work for me
function FitImage( inWidth, inHeight ) {
if ( inWidth == undefined || inHeight == undefined ) {
alert( strWidthAndHeight );
return;
}
var desc = new ActionDescriptor();
var unitPixels = charIDToTypeID( '#Pxl' );
desc.putUnitDouble( charIDToTypeID( 'Wdth' ), unitPixels, inWidth );
desc.putUnitDouble( charIDToTypeID( 'Hght' ), unitPixels, inHeight );
var runtimeEventID = stringIDToTypeID( "3caa3434-cb67-11d1-bc43-0060b0a13dc4" );
executeAction( runtimeEventID, desc, DialogModes.NO );
}
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now