Skip to main content
Participating Frequently
July 26, 2015
Question

Photoshop list actions with script

  • July 26, 2015
  • 6 replies
  • 1913 views

Is there any way to list get all the Actions-scripts with a script?

I am using generate-core to talk to photoshop.

This topic has been closed for replies.

6 replies

Participating Frequently
August 13, 2015

cTID is a function that i have created. Function cTID(s As String) As Integer     Return _appPs.CharIDToTypeID(s) End Function

Participating Frequently
August 13, 2015

Yes, i just got it to work sort of... The problem is now that it skip the last Action Group and can not real get it to list the actions. I made also a question over at Stack Overflow http://stackoverflow.com/questions/31996250/vb-net-photoshop-application

Inspiring
August 13, 2015

Your VB code looks okay (as far as I can tell), you just need to replace cTID with the VB equivalent of app.charIDToTypeID(s).

Participating Frequently
August 13, 2015

I get a error "Additional information: General Photoshop error occurred. This functionality may not be available in this version of Photoshop." on cTID("Actn")

Inspiring
August 13, 2015

The cTID function is defined at the top of the getActionSets function so I have no clue what the error is for.

Inspiring
July 26, 2015

This will get you an array of action set objects which each have a list of actions that they contain:

function getActionSets() {

  function cTID(s) { return app.charIDToTypeID(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;
};

If you need scripts, that's a different bit of code.

Participating Frequently
July 26, 2015

Thanks! Would love more info how to use that function. Do i use it on evaluateJSXString function or can i use it like this?

(function () {

    "use strict";

    function init(generator) {

        var _generator = generator;

        var a = getActionSets();

        console.log("plugin started");

        console.log(a);

    }

    exports.init = init;

}());

Inspiring
July 26, 2015

I don't use generator so someone else will have to help you there.

Chuck Uebele
Community Expert
Community Expert
July 26, 2015

Moving post to scripting forum.

c.pfaffenbichler
Community Expert
Community Expert
July 26, 2015