Skip to main content
Known Participant
June 3, 2011
Question

how to get a list of available actions

  • June 3, 2011
  • 1 reply
  • 830 views

Is there a predefined object type in Extend Script that contains an array of all the actions available from the Presets->Actions folder?

Thanks!

1 reply

Inspiring
June 3, 2011

No DOM interface is available, but here's some code for ya:

function cTID(s) { return app.charIDToTypeID(s); };

function getActionSets () {

  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;
};

JJ_FulksAuthor
Known Participant
June 3, 2011

Thanks, xbytor2! This helps a lot.