Highlighted

Execute JavaScript in Photoshop CC 2019 via Applescript

Community Beginner ,
Jan 24, 2020

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.

 

 

TOPICS
Actions and scripting, How to, Mac

Views

555

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Execute JavaScript in Photoshop CC 2019 via Applescript

Community Beginner ,
Jan 24, 2020

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.

 

 

TOPICS
Actions and scripting, How to, Mac

Views

556

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 24, 2020 0
Adobe Community Professional ,
Jan 24, 2020

Copy link to clipboard

Copied

If I'm right 'do javascript' is not Photoshop, but Illustrator specific.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 24, 2020 0
Community Beginner ,
Jan 24, 2020

Copy link to clipboard

Copied

This is from the scripting guide on page 80.

 

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 24, 2020 0
Adobe Community Professional ,
Sep 05, 2020

Copy link to clipboard

Copied

That's right, I forgot it's special command for Apple Script.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 05, 2020 0
Adobe Community Professional ,
Jan 24, 2020

Copy link to clipboard

Copied

Try here, inline code works fine, but an external reference does not:

 

https://community.adobe.com/t5/photoshop/request-add-scale-styles-option-to-quot-resize-image-quot-c...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 24, 2020 0
Contributor ,
Jan 25, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 25, 2020 0
Most Valuable Participant ,
Jan 25, 2020

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 );
}

 

JJMack

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 25, 2020 0
Adobe Community Professional ,
Jan 25, 2020

Copy link to clipboard

Copied

I can not and do not use applescript.

But
 
1. Try to assign a hotkey to the script and send this keyboard shortcut to Photoshop instead of "do javascript".

2. Try to call the script through the menu.

Not sure if anything will work out.

I found information on how to do it here https://mac4translators.blogspot.com/2017/10/what-is-system-events.html
 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 25, 2020 0