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!

Scripting In need of a script to run Photoshop Actions at startup!


kashacl

New Member
Messages
4
Likes
0
Good afternoon,

I'm in need of a Script to automatically run my photoshop actions at startup. I work with actions all day long and create multiple actions throughout the day. This wouldn't be a problem normally but with the company we have five computers and all of them require the SAME actions so that anything and everything can be run on any computer. It's not so bad when I'm alone and have the time to manually update or load the actions in each computer. But I would like Photoshop to grab the actions automatically at startup from ONE file on a server. I know I can create a script but I'm useless at them and I'm wondering if anyone out there has one I can either purchase or download freely. (P.S. The script must work with ALL versions of Photoshop CS and up.)

Thx,
Kasha.
 
I think you will be out of luck, as to run an action or script on startup you would require "Script Event Manager" and this was implemented in CS2. So CS versions would have to be manually triggered and that is if it is even possible! I don't know if the CS2+ code would work with CS.

You also mentioned a single file, do you mean all your actions are in one atn file?

Would you need to unload the existing atn(s) if it/they exists before loading the new one(s)?

It should be possible to script this, but saving existing atns still can not be done with a script, so a back-up of the atn files should be done.
 
Hey,

Thx for replying.

We do have later versions of CS (like CS2, 3 and 4 and are currently in the works of getting CS5). I was kinda hoping for a script that worked with CS because all the current scripts I utilize only work with CS (because it was the only version my boss had bought when they were all created. PS: I didn't do them which is why I can't create the one I need or modify the old ones.) But I would take one that works with later versions if someone has one.

As for my actions, all the ones I do utilize are in one set (or one atn file). They would need to be unloaded before Photoshop is shut down but I can easily show my coworkers how to do that and it's not so bad if they forget. The only reason I want the set to be loaded on startup is that so none of the actions that are required for some of our scripts will be forgotten. (That just creates a huge mess for me to clean up.) Also, if I know that I do a change to the set (always in the same location) that the next time someone starts their photoshop, it will be the set with my changes. My coworkers aren't very good with photoshop so anything I can automate is better. Hell, if I could I would have the computers start up automatically at 5 am, open photoshop, load the actions and update the actions whenever someone makes a change then reload and replace the set for anyone who has photoshop working. (of course there would be a message alerting the user that changes are going to be updated) But that's just me.

I'm sorry for the novel I'm writing, do you know of someone who might have a script for CS2 and later to load a set of actions on startup? My programmer is currently extremely busy and if I can take this load off his shoulders it would be great! Unless you wanna walk me through editing a script and creating a new one?! :wink:

Thx, again!
 
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));

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 );
};
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!
 
Hey! Thx for the help... I haven't implemented it yet but it's a start for me... I'll let you know if everything works out! Thx again!
 
There is a method called doAction() on the Application class.
You can write a script where you enter the names of the actions you want to run.
Something like this:
app.doAction("myActionName", "myActionSet");
and save the file as .jsx

To have the script run on startup go to File->Scripts->Script Events Manager.
Check the box 'Enable Events to Run Scripts/Actions' and then browse to the script file you want to run. Click the Add button. The script should be added to the list.

I only work in versions CS4 and later so I don't know if the advice above will work for earlier versions.
I hope this helps
cheers
Barb
 

Back
Top