Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 87158

Re: Organizing actions alphabetically

$
0
0

Do you want the script to reorder actions in a set in the actions palette or do you want to create a dialog that you can select a loaded action set and get the actions in it in a sorted list. I think the dialog would be possible by sorting the arrays of retrieve loaded actions set names and sorting retrieved actions names.  There was a package available at one time for organizing ones Action palette.  It most like used Action manager code to delete loaded action sets and to load action sets.  I never downloaded it.  I did download a script that put up a dialog that let you select a loaded action an run it.  The script name RunAction.jsx here it is:

#target photoshop
app.bringToFront();
function main(){
var dlg=
"dialog{text:'Action Selector',bounds:[100,100,510,240],"+
"panel0:Panel{bounds:[10,10,400,130] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+
"statictext0:StaticText{bounds:[30,10,280,30] , text:'Run Action' ,properties:{scrolling:undefined,multiline:undefined}},"+
"ActionSet:DropDownList{bounds:[10,40,190,60]},"+
"ActionName:DropDownList{bounds:[200,40,380,60]},"+
"button0:Button{bounds:[20,80,120,100] , text:'Ok' },"+
"button1:Button{bounds:[240,80,340,100] , text:'Cancel' }}}";
win = new Window(dlg);
win.center();


var actionSets = new Array();
actionSets = getActionSets();
for (var i=0,len=actionSets.length;i<len;i++) {  item = win.panel0.ActionSet.add ('item', "" + actionSets[i]);    
};
win.panel0.ActionSet.selection=0;


var actions = new Array();
actions = getActions(actionSets[0]);
for (var i=0,len=actions.length;i<len;i++) {  item = win.panel0.ActionName.add ('item', "" + actions[i]);    
};
win.panel0.ActionName.selection=0;


win.panel0.ActionSet.onChange = function() {
win.panel0.ActionName.removeAll();
actions = getActions(actionSets[parseInt(this.selection)]);
for (var i=0,len=actions.length;i<len;i++) {  item = win.panel0.ActionName.add ('item', "" + actions[i]);  }  win.panel0.ActionName.selection=0;
};
var done = false;    while (!done) {      var x = win.show();      if (x == 0 || x == 2) {        win.canceled = true;        //Cancelled        done = true;      } else if (x == 1) {        done = true;       var result = valiDate();        if(result != true) {        alert(result);        return;        }else        {        alert(win.panel0.ActionName.selection.text + " " + win.panel0.ActionSet.selection.text);        doAction(win.panel0.ActionName.selection.text, win.panel0.ActionSet.selection.text);        }      }   }
}


main();


function valiDate(){


return true;
};


function getActionSets() {
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
  var i = 1;  var sets = [];  while (true) {    var ref = new ActionReference();    ref.putIndex(cTID("ASet"), i);    var desc;    var lvl = $.level;    $.level = 0;    try {      desc = executeActionGet(ref);    } catch (e) {      break;    // all done    } finally {      $.level = lvl;    }    if (desc.hasKey(cTID("Nm  "))) {      var set = {};      set.index = i;      set.name = desc.getString(cTID("Nm  "));      set.toString = function() { return this.name; };      set.count = desc.getInteger(cTID("NmbC"));      set.actions = [];      for (var j = 1; j <= set.count; j++) {        var ref = new ActionReference();        ref.putIndex(cTID('Actn'), j);        ref.putIndex(cTID('ASet'), set.index);        var adesc = executeActionGet(ref);        var actName = adesc.getString(cTID('Nm  '));        set.actions.push(actName);      }      sets.push(set);    }    i++;  }  return sets;
};


function getActions(aset) {
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
  var i = 1;  var names = [];  if (!aset) {    throw "Action set must be specified";  }  while (true) {    var ref = new ActionReference();    ref.putIndex(cTID("ASet"), i);    var desc;    try {      desc = executeActionGet(ref);    } catch (e) {      break;    // all done    }    if (desc.hasKey(cTID("Nm  "))) {      var name = desc.getString(cTID("Nm  "));      if (name == aset) {        var count = desc.getInteger(cTID("NmbC"));        var names = [];        for (var j = 1; j <= count; j++) {          var ref = new ActionReference();          ref.putIndex(cTID('Actn'), j);          ref.putIndex(cTID('ASet'), i);          var adesc = executeActionGet(ref);          var actName = adesc.getString(cTID('Nm  '));          names.push(actName);        }        break;      }    }    i++;  }  return names;
};

Viewing all articles
Browse latest Browse all 87158

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>