Copy link to clipboard
Copied
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.
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.
cntnt='load(File(path+"/Presets/Actions/gL Print Preflight.atn"))';
(bt = new BridgeTalk()).target='photoshop', bt.body=cntnt, bt.send()
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
You may either insert an item or record it. In 2nd case you'll see full path in opposed to name.
Copy link to clipboard
Copied
I am still having a problem;
When I select from the menu FILE>SCRIPTS>loadActionSet_PrintPreflight
the Action Set loads (Yeah!!!)
app.load(File(app.path+"/Presets/Actions/gL Print Preflight.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 );
};
But, when I create an action and insert as menu item OR record, nothing happens...
You mention in 2nd case I will see a full path but, that is not my case.
Note, I checked and cleared attr. (attributes)
I've also uninstalled and reinstalled Photoshop.
Still, I am not able to create an action that runs this javascript, which I copied, I have not done any programming in a long time.
TIA
Copy link to clipboard
Copied
When you record choosing the script, the action item should display its path, when you insert it then only its name. When inserting nothing happens indeed until you play the action.
Copy link to clipboard
Copied
Looking at your screenshot, both have been inserted.
Inserting an installed script is cleaner if you are running the action on multiple computers.
Here is a screenshot example of inserting vs. recording the browse command. Also note that this does not apply to button mode, which is logical:
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Great info. Thank you, I did make the decision to design the script for cross platform use. After I get the script working I will no doubt be back here asking how to package for cross-platform use 😉
Right now I have the Load Action Set using an absolute path. I will need to change that, but that's a new subject .
Copy link to clipboard
Copied
clearAction("Set 1"); //Clears a specific action set from the Action palette based on its name
function clearAction(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 );
}
Copy link to clipboard
Copied
Thank you for sharing!
Copy link to clipboard
Copied
//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 );
}
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thank you, I've cleaned up the code here;
function loadActions () {
var actionFile = new File(app.path+"/Presets/Actions/gL Print Preflight.atn");
if(!actionFile.exists){
alert("Action file does not exist!");
return;
}else{ app.load(actionFile);}
};
loadActions ();
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
@Bojan Živković 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!
Copy link to clipboard
Copied
3 Days and nothing still working. I've re-installed photoshop.
"gL Print Preflight.jsx" is installed with password in Scripts/ folder
Here is the javascript code.
function loadActions () {
var actionFile = new File(app.path+"/Presets/Actions/gL Print Preflight.atn");
if(!actionFile.exists){
alert("Action file does not exist!");
return;
}else{ app.load(actionFile);}
};
loadActions ();
Manually selecting FILE> SCRIPTS> gL Print Preflight WORKS and loads the Action Set in the Actions palette.
But when pressing "play"; none of these work;
-Browse II is the same file in another location.
I am on a mac. all software up to date.
What else can I try to get this to work?
Copy link to clipboard
Copied
app.load works when my javascript is called manually with FILE > SCRIPTS myjavascript
I see the alert in my javascript "Loading Action Set..." and my Action Set is added to the Actions palette.
When I write an Action script to ie. insert menu item; myjavascript - I still see my alert, but my Action Set is NOT added to the Actions palette.
Is the problem app.load ? Can anyone tell me of alternative code?
my javascript to load an Action Set.
function loadActions () {
var actionFile = new File(app.path+"/Presets/Actions/gL Print Preflight.atn");
if(!actionFile.exists){
alert("Action file does not exist!");
return;
}else{
alert("Loading Action Set..."); // <---- I see that my javascript is called
app.load(actionFile)
};
};
loadActions ();
Copy link to clipboard
Copied
correction: I posted a test file
should be:
app.load(actionFile);
Entire code: This code works if double clicked in the Finder (mac) or called within Photoshop File > Scripts
But NOT with Action script ie. insert menu item > Scripts
function loadActions () {
var actionFile = new File(app.path+"/Presets/Actions/gL Print Preflight.atn");
if(!actionFile.exists){
alert("Action file does not exist!");
return;
}else{
alert("Loading Action Set..."); // <---- I see that my javascript is called
app.load(actionFile);
};
};
loadActions ();
again, the alert "Loading Action Set..." is being displayed in both cases. But app.load not working in Action script.
Copy link to clipboard
Copied
I can reproduce the behaviour, you have apparently found a very specific limitation.
Using an action to execute a script that loads an action set into the action panel does not appear to be supported. As you say, other code executes, such as an alert, but not the code to load the action set.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
cntnt='load(File(path+"/Presets/Actions/gL Print Preflight.atn"))';
(bt = new BridgeTalk()).target='photoshop', bt.body=cntnt, bt.send()
Copy link to clipboard
Copied
Whoah! It works just like I need! This is a game changer for me ! 5**** service.
A separate palette would be ideal - but that's too much programming for me.
Thank you all for being patient with me before I could discover/describe the underlying problem - thanks to the post 2016.
Question: For further installations on other computers in my business; Will I have to install Extendscript on those compters for BridgeTalk method ?