What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Reply to thread

You will need to use ExtendScript Toolkit (ESTK), this gets installed with Photoshop

and is the integrated development environment (IDE).

This utility can be found in the relevant folder:-

PC: C:\Program Files\Adobe\Adobe Utilities

MAC: <hard drive>/Applications/Utilities/Adobe Utilities

Note: CS3 or CS4 ExtendScript Toolkit will be the best.

 

First put the ActionSet.atn on your server.

Now you need to get the correct path to this file so run the following code in a new window, this will then write the correct path to the ESTK Console

so that it can be copied and pasted into the script.

 

[code]

var ATN = File.openDialog("Please select Action Set file.","ATN File:*.atn");

if(ATN != null) $.writeln(decodeURI(ATN));

[/code]

 

Here is the actual code that will unload the ActionSet if it exists then load the new one.

[code]

function main(){

//Paste your path and filename below.

//////////////////////////////////////////////////////////////////////////////////////

var atnFile = new File("//Paulr-pc/i/Test Area/Special Actions.atn");

//////////////////////////////////////////////////////////////////////////////////////

var rex = new RegExp (decodeURI(atnFile.name.replace(/\.[^\.]+$/, '')), "g");

//Check if atn file exists

if(!atnFile.exists){

    alert("You ActionSet does not exist!\Please contact your administrator.");

    return;

    }

//Get a List of all ActionSets

var actionList =getActionSets();

//if ActionSet Exists remove it.

for(var d in actionList){

if(decodeURI(actionList[d]).match(rex)) unLoadAction(actionList[d]);

 }

//Load the action set

app.load(atnFile);

//Check it loaded ok

var actionList =getActionSets();

var flag = false;

for(var d in actionList){

if(decodeURI(actionList[d]).match(rex)) flag=true;

 }

if(!flag){

   alert("The ActionSet did not load\nPlease contact the administrator");

   return;

    }

}

main();

function getActionSets() {

cTID = function(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;

    } 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 unLoadAction(aSet){

var desc = new ActionDescriptor();

var ref = new ActionReference();

ref.putName( charIDToTypeID( "ASet" ), decodeURI(aSet));

desc.putReference( charIDToTypeID( "null" ), ref );

executeAction( charIDToTypeID( "Dlt " ), desc, DialogModes.NO );

};

[/code]

Note: Photoshop CS uses Filename.js but Photoshop CS2 or newer uses Filename.jsx (extended)

If you are using windows Vista/Windows 7 you will need to save the script somewhere you will access (DeskTop will do)

Then copy the script to:

PC: C:\Program Files\Adobe\Adobe Photoshop CS#\Presets\Scripts\Event Scripts Only

MAC: <hard drive>/Applications/Adobe Photoshop CS#/Presets/Scripts/Event Scripts Only

# being the CS version

If Photoshop was open close and restart it so that it can pick up the new script.

Now you need to set up:-

File - Script Events Manager

Tick Enable Events to run Scripts/Actions

Select Photoshop Event: Start Application

Select your new script from the next dropdown box

Click Add

 

Thats it you are done.

There may be a startup folder for CS that you could put the script into (with a .js extension) but can't remember that far back.

Good Luck!


What is our favorite program/app? (Hint - it begins and ends with the letter P)
Back
Top