Skip to main content
Inspiring
September 8, 2021
Answered

From the Ps action palette in button mode - I want to run a javascript.

  • September 8, 2021
  • 4 replies
  • 4112 views

From the Ps action palette in button mode - I simply want the action to run a javascript file. I have a javascripts that load and unload actions sets to keep from having too many distracting buttons and having to scroll in the action palette.

 

I currently can drag and drop javascript files into Ps, and Ps load and unloads the Actions Sets nicely to reduce the clutter.

BUT, I want to get rid dragging and dropping js files into photoshop. It breaks the the rythme of workflow. I should be able to work WITHIN photoshop. Photoshop doesn't allow me to load / unload sets [programmatically with a Ps Action ]

 

I want like this;

Action pallette (button mode);

   action1

   action2

   action3

NEXT TASK...

 

where NEXT TASK is an action that somehow executes a javascript file.

 

 

TIA for any help.

This topic has been closed for replies.
Correct answer Kukurykus

Thank you very much for your interest and taking the time to re-produce the error.

 

I believe it's a thread problem. The link below explains it much better than I can.

The solution is to tell another application to launch the javascript much like I do in the mac Finder by double-clicking on the code -- A new thread coming from a different application.

 

The link below is from 2016 and I cannot get the code to work today. I think the javascript is telling Bridge (ref:Bridgetalk?) to launch the code. 

 

Unable to load action while an action is running?

 

Whether there is a method to launch a new thread through Bridge or the Finder. I am in search of a solution.


 

cntnt='load(File(path+"/Presets/Actions/gL Print Preflight.atn"))';
(bt = new BridgeTalk()).target='photoshop', bt.body=cntnt, bt.send()

 

4 replies

Bojan Živković11378569
Community Expert
Community Expert
September 9, 2021

You should be able to record action step to play script file. You must provide us more info like where is located your script and what you have recorded in action step. I am testing to run single step action with recorded script from File > Scripts in button mode and everything works fine.

By the way, nothing changed recently in development but maybe it is worth to know your platform (you have tagged both) and Ps version number.

Inspiring
September 9, 2021

@Bojan Živković11378569 wrote:

You should be able to record action step to play script file.


 

 I am embarrassed to say that after 30 years of using photoshop since photoshop 2.0 when it came on a two 3.5" disks, I have never integrated javascript with photoshop.

 

I am still learning the power of this marvelous program! 

Stephen Marsh
Community Expert
Community Expert
September 9, 2021

Whether you install the script or simply record its use into an action as an absolute path is up to you (installing is best for multiple users or cross-platform use).

 

Downloading and Installing Adobe Scripts

 

@contactzero – can you please share the script for loading/unloading actions?

Inspiring
September 9, 2021
//Load a specific Action Set based on its path name
app.load(File("/Users/.../" + "Set 1.atn")); //Load the action based on it's name from a pre-specified path
function loadActionSet(aName) {
    var idDlt = charIDToTypeID( "Dlt " );
    var desc1 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
    var ref1 = new ActionReference();
    var idASet = charIDToTypeID( "ASet" );
    ref1.putName( idASet, aName );
    desc1.putReference( idnull, ref1 );
    executeAction( idDlt, desc1, DialogModes.NO );
}
Stephen Marsh
Community Expert
Community Expert
September 10, 2021

Thanks... Is this code complete?

 

The only part of the code that appears to be needed is a single line:

 

app.load(File("~/Desktop/myActionSet.atn"));

 

The function "loadActionSet" is either incomplete or unnecessary? There is no call to this function.

Kukurykus
Legend
September 8, 2021

Save your .jsx to 'Presets / Scripts' folder of your Photoshop which you have to relaunch. When you have action (in action set) selected, Insert Menu Item from top right corner expandable menu. Then click on the appropriate item in the 'File / Scripts' menu.

Inspiring
September 9, 2021

Thank you,

I am going to try this angle, maybe recording an action that can select a menu item in the Scripts menu as mentioned by JJMac.

 

Kukurykus
Legend
September 9, 2021

You may either insert an item or record it. In 2nd case you'll see full path in opposed to name.

JJMack
Community Expert
Community Expert
September 8, 2021

If you put you Photoshop Javascripts into Photoshop Scripts path they will be available in  Photoshop  menu File>Scripts>Script Name List.  Then you can edit  your Photoshop Keyboard Shortcuts and add Shortcuts for your  Photoshop Scripts.  No need to drag/drop, no need to use Photoshop's slow scrolling menu File>Scripts>Script Name Lists scrolling.  A tap of a short is all that is required.  I add a link into all  install Photoshop versions scripts folder to my Photoshop Scripts tree.  All versions of photoshop installed on my machine use the same script file.It the easy way to install your personal scripts into Photoshop.  You can also record the use of your Scripts in Action steps when your Scripts are in Photoshop's scripts path.

 

Keyboard Shortcuts can be saves and shared between photoshop versions.

JJMack
Inspiring
September 9, 2021

JJMack wrote:


@JJMack wrote:

... You can also record the use of your Scripts in Action steps when your Scripts are in Photoshop's scripts path.

 

If this means I can make an Action step (a button in button mode), this will work. I'll give it a try and report back here.

 

I have many action sets and I want to make loading / unloading them interactive within photoshop. I would soon run out of keyboard shortcuts and/or the shortcuts would not be compatible from maching to machine if I were to migrate my Actions onto other machines in my businesses workflow. So the button mode is my only option.

 

I'm excited if this works!