Return a list of actions for the user to choose from.

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

rcooper102

Return a list of actions for the user to choose from.

Post by rcooper102 »

Hey so I have been searching for this one for ages but the term "action" is just too generic and makes it impossible to google with any real accuracy.

So anyway, I am using the doAction() method to run a user defined action after the script has completed. Right now I am just using a text box that lets the user enter in the action name but this obviously becomes a problem if they mistype the action name or type one that does not exist.

Thus instead I was hoping to be able to use a drop down menu to allow them to select the action and then action set but I can't seem to find any way in the documentation that talks about how to get these lists?

thanks!!

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Paul MR

Return a list of actions for the user to choose from.

Post by Paul MR »

Here is one example...

Code: Select allalert(getActionSets().join('\r'));
alert(getActions(getActionSets()[0]).join('\r'));


function getActionSets(){
var ref = new ActionReference();
ref.putIndex(charIDToTypeID('ASet'), 1);
var desc = executeActionGet(ref);
var aSets=[];
var z = 1;
while(true){
var ref = new ActionReference();
ref.putIndex(charIDToTypeID('ASet'), z);
try{
var desc2 = executeActionGet(ref);
var actName = desc2.getString(charIDToTypeID('Nm  '));
aSets.push(actName);
z++;
}catch(e){return aSets;}
}
};

function getActions(aSet){
var names = [];
var z =1;
while(true){
var ref = new ActionReference();
ref.putIndex(charIDToTypeID('Actn'), z);
ref.putName(charIDToTypeID('ASet'), aSet);
try{
var adesc = executeActionGet(ref);
var actName = adesc.getString(charIDToTypeID('Nm  '));
names.push(actName);
z++;
}catch(e){return names;}
    }
};

rcooper102

Return a list of actions for the user to choose from.

Post by rcooper102 »

perfect tyvm