Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Execute JavaScript in Photoshop CC 2019 via Applescript

Community Beginner ,
Jan 24, 2020 Jan 24, 2020

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
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
LEGEND ,
Jan 24, 2020 Jan 24, 2020

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 24, 2020 Jan 24, 2020

This is from the scripting guide on page 80.

 

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 05, 2020 Sep 05, 2020
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 24, 2020 Jan 24, 2020

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

 

Request: Add Scale Styles option to "resize image" command in AppleScript

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jan 25, 2020 Jan 25, 2020

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 25, 2020 Jan 25, 2020

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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 25, 2020 Jan 25, 2020
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 What is "System Events"?
 
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines