Quantcast
Channel: Adobe Community : Popular Discussions - Photoshop Scripting
Viewing all 12244 articles
Browse latest View live

Automatically run scripts on files in a specific folder

$
0
0

Hello all!

 

I have a series of very effective scripts that I am running against a series of photoshop files. Now the big quiestion!

 

Is there a program to

1) "watch" a folder, so when a file is saved in that folder.

 

2) It runs my script(s) on that file?

 

If you look at it simply-- I would like to replace the "drag and drop" method used for droplets, with the "drop in the folder" method.

No doubt this would require a separate program, to consistently check the folder for new files.

 

This is something that I would prefer to tackle with python, but maybe you all in the community could provide me with a more "industry accepted" solution?

 

Oh and Ideally I would run this on both mac and PC.... though I understand if windows makes more  sense for an operation like this.

 

Best,

Thomas Murphy


Object, Property, Method or parameter for new Pixel Layer Properties in Properties Panel

$
0
0

In Photoshop CC 2017 there is a new property panel "Pixel Layer Properties".

 

 

How do I get its values using Photoshop Javascript? I have a script which do certain action based upon layer condition. I want to add a condition at line #37 that if W*H from "Pixel Layer Property" is equal to or greater than 3/4 of Canvas dimension then goto line # 71 and skip the execution of lines #38 to #68 otherwise execute the next line (i.e. # 38). I made it from my other actions and some scripts using ActionToJavascript. I Can do minor manipulation in Javascripts and also I do read the Photoshop Javascript reference 2015, but there is nothing there for "Pixel Layer Properties" because it introduced in 2017.

 

Here is my script:

 

#target photoshop
//
// Conditional Layer Removal PSD JPG.jsx
// Conditional Removal of ID Layer based upon number of layer in a PSD


//
// Generated Sat Jul 29 2017 00:59:28 GMT+0500
//


cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
var layerCount = app.activeDocument.layers.length;
    if (layerCount > 2)    {
//
//==================== RemoveIDLayer ==============
//
function RemoveIDLayer() {  // Select  function step1(enabled, withDialog) {    if (enabled != undefined && !enabled)      return;    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);    var desc1 = new ActionDescriptor();    var ref1 = new ActionReference();    ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Frnt'));    desc1.putReference(cTID('null'), ref1);    desc1.putBoolean(cTID('MkVs'), false);    var list1 = new ActionList();    list1.putInteger(9);    desc1.putList(cTID('LyrI'), list1);    executeAction(cTID('slct'), desc1, dialogMode);  };  // Delete  function step2(enabled, withDialog) {    if (enabled != undefined && !enabled)      return;    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);    var desc1 = new ActionDescriptor();    var ref1 = new ActionReference();    ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));    desc1.putReference(cTID('null'), ref1);    var list1 = new ActionList();    list1.putInteger(9);    desc1.putList(cTID('LyrI'), list1);    executeAction(cTID('Dlt '), desc1, dialogMode);  };  // Select  function step3(enabled, withDialog) {    if (enabled != undefined && !enabled)      return;    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);    var desc1 = new ActionDescriptor();    var ref1 = new ActionReference();    ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Frnt'));    desc1.putReference(cTID('null'), ref1);    desc1.putBoolean(cTID('MkVs'), false);    var list1 = new ActionList();    list1.putInteger(9);    desc1.putList(cTID('LyrI'), list1);    executeAction(cTID('slct'), desc1, dialogMode);  };  // Trim  function step4(enabled, withDialog) {    if (enabled != undefined && !enabled)      return;    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);    var desc1 = new ActionDescriptor();    desc1.putEnumerated(sTID("trimBasedOn"), sTID("trimBasedOn"), sTID("topLeftPixelColor"));    desc1.putBoolean(cTID('Top '), true);    desc1.putBoolean(cTID('Btom'), true);    desc1.putBoolean(cTID('Left'), true);    desc1.putBoolean(cTID('Rght'), true);    executeAction(sTID('trim'), desc1, dialogMode);  };  // Trim  function step5(enabled, withDialog) {    if (enabled != undefined && !enabled)      return;    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);    var desc1 = new ActionDescriptor();    desc1.putEnumerated(sTID("trimBasedOn"), sTID("trimBasedOn"), sTID("bottomRightPixelColor"));    desc1.putBoolean(cTID('Top '), true);    desc1.putBoolean(cTID('Btom'), true);    desc1.putBoolean(cTID('Left'), true);    desc1.putBoolean(cTID('Rght'), true);    executeAction(sTID('trim'), desc1, dialogMode);  };    // Scripts  function step6(enabled, withDialog) {    if (enabled != undefined && !enabled)      return;    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);    var estr = '//@include "~/OneDrive/Business/Website Making/Commands and Scripts/Adobe Scripts/Conditional resizeImage 1100 All.jsx";\r\n';    eval(estr);  };


// Canvas Size
  function step7(enabled, withDialog) {    if (enabled != undefined && !enabled)      return;    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);    var desc1 = new ActionDescriptor();    desc1.putBoolean(cTID('Rltv'), true);    desc1.putUnitDouble(cTID('Wdth'), cTID('#Pxl'), 300);    desc1.putUnitDouble(cTID('Hght'), cTID('#Pxl'), 300);    desc1.putEnumerated(cTID('Hrzn'), cTID('HrzL'), cTID('Cntr'));    desc1.putEnumerated(cTID('Vrtc'), cTID('VrtL'), cTID('Cntr'));    desc1.putEnumerated(sTID("canvasExtensionColorType"), sTID("canvasExtensionColorType"), cTID('BckC'));    executeAction(sTID('canvasSize'), desc1, dialogMode);  };


// Scripts
  function step8(enabled, withDialog) {    if (enabled != undefined && !enabled)      return;    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);    var estr = '//@include "~/OneDrive/Business/Website Making/Commands and Scripts/Adobe Scripts/PSDtoJPG.jsx";\r\n';    eval(estr);  };  // Close  function step9(enabled, withDialog) {    if (enabled != undefined && !enabled)      return;    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);    var desc1 = new ActionDescriptor();    desc1.putEnumerated(cTID('Svng'), cTID('YsN '), cTID('N   '));    desc1.putInteger(cTID('DocI'), 816);    desc1.putBoolean(sTID("forceNotify"), true);    executeAction(cTID('Cls '), desc1, dialogMode);  };  step1();      // Select  step2();      // Delete  step3();      // Select  step4();      // Trim  step5();      // Trim  step6();      // Scripts  step7();      // Canvas Size  step8();      // Scripts  step9();      // Close
};






//=========================================
//                    RemoveIDLayer.main
//=========================================
//


RemoveIDLayer.main = function () {
  RemoveIDLayer();
};


RemoveIDLayer.main();


// EOF


"Conditional Layer Removal PSD JPG.jsx"
// EOF
    }
else app.doAction ("< 2 Layer removal PSD", "My Actions") 

 

Message was edited by: Junaid Junaid

Does the cloud overwrite my Image Processor script?

$
0
0

Feeling a little paranoid here, but what the heck?

 

Following the instructions in this thread:

 

https://forums.adobe.com/message/3012206

 

I have adapted my Image Processor script to output TIFs as smart objects. Works great, and I use Image Processor Pro when I want regular TIFs.

 

Problem is, every time I restart my machine (or by some other unknown vehicle) my adapted script gets overwritten by the regular Image Processor script.

 

I tried changing the name of my script but then it wont run.

 

But why wont my script stay put?

 

Tired of having to reinstall it every time I want to use it!

Place images to a specific spot in a template

$
0
0

I am trying to create an action that will drop images into a specific spot in another document and save it with a certain file name. After the first image is dropped in and saved, I want my next image to do the same and so on. I have all my images cropped to the correct ratio and being pulled from a folder on my desktop. I have my template open in Photoshop where I want my images from that folder to be dropped into. Is this possible?

 

Any help is greatly appreciated!!

 

Melissa

Script I made: Iterate Action Over Layers

$
0
0

Hey, just cobbled together this script that I'm already finding useful in my own work, so I figured I'd share, and maybe see if anyone has suggestions for improvement.

What it does, is apply a selected action to each of the selected layers individually.

So for example, if you had 50 layers that you wanted to each rotate by 90 degrees in place, you'd record a rotate-by-90-degrees action, select all the layers you want to apply it to and run the script with the action selected.

 

 

#target photoshop


var scriptName = "NinjaScript IterateActionLayers";
var scriptVersion = "0002";


function cID (inVal) { return charIDToTypeID(inVal);}
function sID (inVal) { return stringIDToTypeID(inVal);}


var currentActionSets = getActionSets();


main();
function main()
{
    app.bringToFront();    optionsDialog();
}


function optionsDialog()
{
    var ButtonWidth = 100;      OpenOptionsDialog = new Window("dialog", scriptName + " v" + scriptVersion);  OpenOptionsDialog.orientation = 'column';  OpenOptionsDialog.alignChildren = 'left';    mainGroup = OpenOptionsDialog.add("group");    mainGroup.orientation = 'column';    mainGroup.alignChildren = 'left';    mainGroup.alignment = 'left';         var actionSetGroup = mainGroup.add("group");    actionSetGroup.orientation = 'row';    actionSetGroup.add("statictext",undefined, "ActionSet: ")    var DDActionSet = actionSetGroup.add("dropdownlist",undefined, "")    DDActionSet.preferredSize.width = 150;           for (var i = 0; i < currentActionSets.length; i++)    {            DDActionSet.add("item", currentActionSets[i]);    }    DDActionSet.selection = 0;                  var actionGroup = mainGroup.add("group");    actionGroup.orientation = 'row';    actionGroup.add("statictext",undefined, "Action:      ")    DDActions = actionGroup.add("dropdownlist",undefined, "")    DDActions.preferredSize.width = 150;        function populateDDActions (inSet)    {        DDActions.removeAll();                for (var i = 0; i < currentActionSets[inSet].actions.length; i++)        {            DDActions.add("item", currentActionSets[inSet].actions[i]);        }        DDActions.selection = 0;    }    DDActionSet.onChange = function()    {        populateDDActions(DDActionSet.selection.index);    }    DDActionSet.onChange();        mainGroup.add("statictext", undefined, "");         ButtonGroup = mainGroup.add("group");    ButtonGroup.orientation = 'row';    ButtonGroup.alignChildren = 'center';    ButtonGroup.alignment = 'top';                     buttonRun= ButtonGroup.add("button",undefined, "Run")    buttonRun.preferredSize.width = ButtonWidth;    buttonRun.onClick = function()   {       var SelectedLayers = getSelectedLayers();               for (var i = 0; i < SelectedLayers.length; i++)        {            activeDocument.activeLayer = SelectedLayers[i];            doAction(DDActions.selection.text, DDActionSet.selection.text);                    }        OpenOptionsDialog.close()    }        buttonClose= ButtonGroup.add("button",undefined, "Exit")    buttonClose.preferredSize.width = ButtonWidth;    buttonClose.onClick = function() {OpenOptionsDialog.close()}           //Show window  OpenOptionsDialog.center();  var result = OpenOptionsDialog.show();
}


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


function getSelectedLayers()
{
  var resultLayers=new Array();  try{    var descGrp = new ActionDescriptor();    var refGrp = new ActionReference();    refGrp.putEnumerated(cID( "Lyr " ),cID( "Ordn" ),cID( "Trgt" ));    descGrp.putReference(cID( "null" ), refGrp );    executeAction( sID( "groupLayersEvent" ), descGrp, DialogModes.NO );    for (var ix=0;ix<app.activeDocument.activeLayer.layers.length;ix++){resultLayers.push(app.activeDocument.activeLayer.layers[ix])}    var desc5 = new ActionDescriptor();    var ref2 = new ActionReference();    ref2.putEnumerated( cID( "HstS" ), cID( "Ordn" ), cID( "Prvs" ) );    desc5.putReference( cID( "null" ), ref2 );    executeAction( cID( "slct" ), desc5, DialogModes.NO );  } catch (err) { }  return resultLayers;
}   

Script to remove hidden/unused Layer Effects?

$
0
0

Does anyone have, or know if it's possible to remove hidden/unused layer effects of selected layer(s) with a script? (Not on every layer in the document, only selected layers)

 

For example here I'd have to drag each unused effect to the trash can at the bottom

ps remove hidden layer effects.png

 

Would be great if you could remove the hidden ones while still leaving those that are visible via a script

How to open specific folder to select images?

$
0
0

Hello,

How can I open specific folder to select (multiple) images?

I tried this script but it does not open specified folder...What I am doing wrong?

By the way I want to open ;

Adobe\Adobe Photoshop CC Version\Presets\Scripts\Folder

in both mac and pc.

Thank you.

 

 

var myFolder = "/Volumes/[ROOTVOLUME]/Users/[USERNAME]/Desktop/";
var myFiles =  new Array();
var myMask = "*.jpg;*.png;*.tif";  // Supported File Types
myFiles = File.openDialog("Choose your file",myMask,myFolder,true);

Keeping variables across runs of a script

$
0
0

Well, I'm a noob at Photoshop scripting. I knew Javascript, and I've been trying to work my way with the Photoshop DOM for about a month, but now I'm trying to do something that I can't find anywhere, neither in Google nor in the documentation... Sorry if this sounds obvious.

 

First I'm asking to open a PDF file, and then I ask to select a folder where the pages will go. Then I save in an array the file object for the PDF, the folder object, the current page... so I can get it later. Now I open the first page, and stop the script to do some manual work. After that, I would load the script, check if the array where I saved that exists, and if it does, save that page and open the next.

 

Now, I can't find any way to keep variables between runs of a script, nor to keep the script waiting in the background. Somewhere in the Javascript reference it says that the variables are kept, but every time it asks me to select the PDF again. So I'm kind of lost there. Could you help me?

 

By the way, I'm using Photoshop CS5, and I script with Javascript.


Script Unsmart 2.0 is done

$
0
0

I need your help with testing.

Also check settings inside script and try different settings.

 

Download: Magic scripts for Photoshop

Please make sure that you test version 2.0

You also must copy file lexicon inside same folder.

 

Major changes:

- completely rewritten

- added viewless method if smart object has no layer comps

- opening and closing SO window only once if there are multiple instances

- better, faster and more reliable SO active composition detection

- Unsmart can now reproduce more deformations methods

- big performance improvements

- better artboards support for pixel perfect results

- mask is added automaticaly only if layers inside smartObject canvas are outside canvas

 

Reproduces from SO

- pixel mask (including: link, density, feather)

- disabled pixel mask

- vector mask (including: link, density, feather)

- disabled vector mask

- blend modes, fill, opacity

- name

- color tag

- deformation, position, scale

- layer effects scaling including shapes strokes with gradients, patterns ect.

- moves clipped layers to the SO group

- if SO is linked with another layes new SO group will be also linked

 

Can't reproduce

- warp

- SO filters

 

Known issues

- some deformations can't be reproduced with text layers or smart object vector layers. Nearest similar deformation is used.

- you might see different result if smart object has more layer comps but none is selected

- documents may not have compatible modes e.g. bits per pixels, color mode, pixel scaling

overlay two different images (batch)

$
0
0

is a simple way to batch process two folders of images so that say... Folder 1 Image 1 is overlaid on Folder 2 Image 1 to create a composite? I have a series of images I want to overlay on to each other but I am not sure if it's possible other than by opening each by hand which would take ages.

Script Alert: "Sorry I could not process the following files" (Error Message using Image Processor)

$
0
0

I'm a seasoned Photoshop/Bridge CS5 user who recently upgraded to CS6.  In Bridge I just ran my first Image Processor batch, trying to convert a set of RAW .NEF files to .PSD files with a basic editing action I created applied to them.  Photoshop CS6 opens the files from Bridge and applies the actions, but then I get the "Script alert" error message "Sorry I could not process the following files" and a list of all of the files in the batch I was trying to run the script on.  The files all remain open and are saved on my hard drive in a folder created by the Image Processor script, but do not close unless I manually close them.  I never had this problem in CS5 where the image processor would apply the desired actions to the batch of photos one at a time, then save and close.  Thoughts on how I can fix this bug?

Custom Condition for Photoshop Actions

$
0
0

Trying to create a custom "condition" for a complex Photoshop Action.

I have a custom, Unlockbackround.jsx that is in the script menu.

That unlocks the backround layer and then proceeds to group all layers. is there a way to point a condition to a script.?

Right now the condition is

If  back round is locked

play locked backround,

if layer is unlocked then play unlocked backround

 

the problem is if the "back round layer isn't actually clicked on , it dosnt unlock.

 

thats why i wrote the .jsx

Problem is i don't want to deploy the scripts, only the actions to our company. any suggestions welcom

Getting selected layers by script (object refs, not indices!)

$
0
0

Hey guys - I'm working on a simple photoshop CC script that exports selected layers, but I'm having some problems with the selection code.

Googling around I found a helpful snippet that returns a list of layer index values for my selected layers - however the returned indices don't equate to the indices I get when simply using app.activeDocument.layers().

Can anyone suggest a method to get references to the layer objects that are selected? - or perhaps a function to convert the document indices from the function below to their respective layer objects?

 

Many thanks in advance!

 

function getSelectedLayersIdx(){

     var selectedLayers = new Array;

     var ref = new ActionReference();

     ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );

     var desc = executeActionGet(ref);

     if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){

          desc = desc.getList( stringIDToTypeID( 'targetLayers' ));

          var c = desc.count

          var selectedLayers = new Array();

          for(var i=0;i<c;i++){

               selectedLayers.push(  desc.getReference( i ).getIndex());

          }

     }else{

          var ref = new ActionReference();

          ref.putProperty( charIDToTypeID('Prpr') , charIDToTypeID( 'ItmI' ));

          ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );

          selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( 'ItmI' )));

     }

     return selectedLayers;

}

 

var doc = app.activeDocument;

var layersIndx = getSelectedLayersIdx(doc);

alert("Selected layers indx: "+layersIndx);

 

for(i =0; i<layersIndx.length; i++){

    index= layersIndx[i];

    alert("Index: "+index+" Name: "+doc.layers[index].name);

}

How to display PS 'SaveAs' option dialogs, but not file save dialog?

$
0
0

In a JS script we want to display the appropriate  Photoshop image options dialogs for JPEGS, PNGS, TIFFs or PSDs for a Save or SaveAs action to the user - but not show the actual file save dialog - as we need to limit where the file is actually saved to a particular working folder.

 

Is this possible ?

 

Thanks.

Script Events Listener

$
0
0

In continuation of the post Re: Clean SL and at the request of the Kukurykus

I bring to your attention the script event_listener.jsx.

 

It allows you to write events as functions in the file ~/Desktop/EventListener.log.

 

The script needs to be copied to the ..\Presets\Scripts folder.

To activate it, you need to start it manually (It will be located in the menu beside "Script Events Manager").

 

To activate, click "Enable", to deactivate, click "Disable".

 

If you previously installed the notifiers in the Script Events Manager, it is desirable to clear them manually.

 

While this is the first version, but I think that the latter, too.

I do not see any prospects for further development.

 

Maybe someone will suggest ideas or he will start developing the script himself.

 

The script:

<javascriptresource><name>Script Events Listener...</name><category>scriptevents</category></javascriptresource>

var log_name = "~/Desktop/EventListener.log";

var dsc_name = "d";
var lst_name = "list";
var ref_name = "r";

var dsc_numb = 0;
var lst_numb = -1;
var ref_numb = -1;

var tab = "    ";

var silent = false;

var events_CS6 = [ "All " ];

var events_CC = [
"TdT ","Avrg","ASty","Asrt","AccE","Add ","AdNs","AddT","Algn","AngS","AppI","BsRl","Btch","BtcF","Blr ","BlrM","Brdr","BrgC","CnvS","ChlC","ChnM",
"Chrc","Chrm","Cler","Cls ","Clds","ClrB","ClrH","ClrR","ClrP","CntC","Cntc","CnvM","copy","CpFX","CpyM","CpTL","Crql","CrtD","Crop","Crsh","Crst",
"Crvs","Cstm","cut ","CtTL","Ct  ","DrkS","Dntr","DfnP","Dfrg","Dlt ","Dstt","Dslc","Dspc","DfrC","Dfs ","DfsG","dlfx","Dspl","Dstr","Draw","DryB",
"Dplc","DstS","Embs","Eqlz","Exch","Expn","Expr","Extr","Fct ","Fade","Fthr","Fbrs","Fl  ","FlmG","Fltr","FndE","FltI","Flip","Frgm","Frsc","GsnB",
"getd","Gls ","GlwE","Grdn","GrMp","Grn ","GraP","GrpL","Grow","HlfS","Hd  ","HghP","HsbP","HStr","ImgS","Impr","InkO","Intr","IntW","Invs","Invr",
"LnsF","Lvls","LghE","Lnk ","Mk  ","Mxm ","Mdn ","Mrg2","MrgL","MSpt","MrgV","Mztn","Mnm ","Msc ","MscT","MtnB","move","NTSC","NGlw","Nxt ","NtPr",
"Ntfy","null","OcnR","Ofst","Opn ","Pnt ","PntD","PltK","past","PaFX","PstI","PstO","Ptch","Phtc","Pnch","Plc ","Plst","PlsW","Ply ","Pntl","Plr ",
"PstE","Pstr","Prvs","Prnt","PrfT","Prge","quit","RdlB","Rstr","RstT","RmvB","RmvL","RmvW","Rnm ","RplC","Rset","Rtcl","Rvrt","Rple","Rtte","RghP",
"save","slct","SlcC","setd","ShrE","Shrp","ShrM","Shr ","Shw ","Smlr","SmrB","Smth","SmdS","Slrz","Spt ","Sphr","SplC","Spng","SprS","StnG","Stmp",
"Stop","Strk","Sbtr","SbtF","Smie","TkMr","TkSn","TxtF","Txtz","Thrs","Tls ","TrnE","TrcC","Trnf","Trap","Twrl","Undr","undo","Ungr","Unlk","UnsM",
"Vrtn","Wait","WtrP","Wtrc","Wave","Wnd ","ZgZg",
"BacL","FilE","ColE","OpnU",

"rigidTransform",
"perspectiveWarpTransform",
"Adobe Camera Raw Filter",
"smartBrushWorkspace",
"focusMask",
];


if (!arguments.length) 
    {    var events = (parseInt(app.version)==13)?events_CS6:events_CC;    var d = new Window("dialog", "Event Listener 0.01")    d.orientation = "row";    d.spacing = 20;    d.margins = 20;    var b1 = d.add("button", undefined, "Enable");    var b2 = d.add("button", undefined, "Disable");    b1.onClick = function()        {        d.close();        for (var i = 0; i < events.length; i++) enable_notifier(events[i], $.fileName);        alert("Event Listener Enabled!", " ")        }    b2.onClick = function()        {        d.close();        for (var i = 0; i < events.length; i++) disable_notifier(events[i], $.fileName);        alert("Event Listener Disabled!", " ")        }    d.show();    }

if (arguments.length >= 2) main(arguments[0], arguments[1]);

//////////////////////////////////////////////////////////////////////////
function main()
    {    try         {         var func_name = typeIDToStringID(arguments[1]);        if (!func_name) func_name = typeIDToChar(arguments[1]);        if (func_name.toLowerCase().indexOf("modalstate")    >= 0) return;        if (func_name.toLowerCase().indexOf("invokecommand") >= 0) return;        if (func_name.toLowerCase().indexOf("togglebrushesflyout") >= 0) return;        var msg = null;        if (!silent)                       {            msg = new Window("palette", "Event Listener", undefined, {independent:true} );            msg.preferredSize.width = 150;              msg.txt = msg.add("statictext", undefined, func_name);            msg.show();            }        var file = new File(log_name);        file.open("a");        file.writeln("///////////////////////////////////////////////////////////////////////////////");          file.writeln("function " + func_name + "_" + Math.random().toString().substr(2) + " ()");          file.writeln(tab + "{");          file.writeln(tab + "try {");         file.writeln(parse_desc(arguments[0]));        file.writeln(tab + tab + "executeAction(" + k2s(arguments[1]) + ", d, DialogModes.NO);");          file.writeln(tab + tab + "}");        file.writeln(tab + "catch (e) { throw(e); }");        file.writeln(tab + "}");        file.writeln("");        file.close();        if (msg)            {            msg.close();            msg = null;            }        }    catch (e) { _alert(e); }    }

//////////////////////////////////////////////////////////////////////////
function _alert(e)
    {     if (e.number != 8007)         {        alert("Line: " + e.line + "\n\n" +  e, "Bug!", true);         }               }

//////////////////////////////////////////////////////////////////////////
function enable_notifier(event_name, script_name, event_class)
    {    try         {        for (var i = 0; i < app.notifiers.length; i++)            {            if (app.notifiers[i].event == event_name &&                File(app.notifiers[i].eventFile).fsName.toLowerCase() == File(script_name).fsName.toLowerCase())                {                if (!app.notifiersEnabled) app.notifiersEnabled = true;                return true;                }            }        app.notifiers.add(event_name, File(script_name), event_class);        app.notifiersEnabled = true;        return true;        }    catch (e) { _alert(e); return false; }    }

//////////////////////////////////////////////////////////////////////////
function disable_notifier(event_name, script_name, event_class)
    {    try         {        var ret = false;        for (var i = 0; i < app.notifiers.length; i++)            {            if (app.notifiers[i].event == event_name &&                File(app.notifiers[i].eventFile).fsName.toLowerCase() == File(script_name).fsName.toLowerCase())                {                app.notifiers[i].remove();                ret = true;                }            }        if (!app.notifiers.length) app.notifiersEnabled = false;        return ret;        }    catch (e) { _alert(e); return false; }    }

//////////////////////////////////////////////////////////////////////////
function k2s(key)
    {    try         {        var str = typeIDToStringID(key);        var chr = typeIDToCharID(key);        switch (chr)            {            case "Gd  ": str = "guide";  break;            case "Grn ": str = "green";  break;            case "Grns": str = "greens"; break;            case "Pnt ": str = "point";  break;            case "Rds ": str = "";       break;            }        if (str) return "stringIDToTypeID(\"" + str + "\")";        else if (chr) return "charIDToTypeID(\"" + chr + "\")";        else return "Bug!";        }    catch (e) { throw(e); }    }

////////////////////////////////////////////////////////////////////////////////////////////
function dat(s)
    {    try         {        var ret = "String.fromCharCode(";        for (var i = 0; i < s.length; i++)             {            var h = s.charCodeAt(i).toString(16).toUpperCase();            if (h.length == 1) h = "0" + h;            ret += "0x" + h;            if (i != s.length-1) ret += ",";            }        ret += ")";                return ret;        }    catch (e) { throw(e); }    }

//////////////////////////////////////////////////////////////////////////
function parse_desc(desc)
    {    try         {        var name = dsc_name + (dsc_numb?dsc_numb:"");        var code = (dsc_numb?"":(tab + tab)) + "var " + name + " = new ActionDescriptor();";        for (var i = 0; i < desc.count; i++)            {            var key  = desc.getKey(i);            var type = desc.getType(key);            var str = "// UNNKOWN TYPE!";             var var_numb;            switch (type)                 {                case DescValueType.OBJECTTYPE:    ++dsc_numb; var_numb = dsc_numb; str = parse_desc(desc.getObjectValue(key)) + "\n" + tab + tab + name + ".putObject(" + k2s(key)    + ", " + k2s(desc.getObjectType(key)) + ", " + dsc_name + (var_numb?var_numb:"") + ");"; break;                case DescValueType.LISTTYPE:      ++lst_numb; var_numb = lst_numb; str = parse_list(desc.getList(key))        + "\n" + tab + tab + name + ".putList("   + k2s(key)    + ", " + lst_name + (var_numb?var_numb:"") + ");"; break;                case DescValueType.REFERENCETYPE: ++ref_numb; var_numb = ref_numb; str = parse_ref(desc.getReference(key))    + "\n" + tab + tab + name + ".putReference(" + k2s(key) + ", " + ref_name + (var_numb?var_numb:"") + ");"; break;                case DescValueType.CLASSTYPE:        str = name + ".putClass(" + k2s(key) + ", " + k2s(desc.getClass(key))   + ");"; break;                case DescValueType.RAWTYPE:          str = name + ".putData("  + k2s(key) + ", " + dat(desc.getData(key))    + ");"; break;;                 case DescValueType.BOOLEANTYPE:      str = name + ".putBoolean("      + k2s(key) + ", " + desc.getBoolean(key)      + ");"; break;                case DescValueType.INTEGERTYPE:      str = name + ".putInteger("      + k2s(key) + ", " + desc.getInteger(key)      + ");"; break;                case DescValueType.DOUBLETYPE:       str = name + ".putDouble("       + k2s(key) + ", " + desc.getDouble(key)       + ");"; break;                case DescValueType.LARGEINTEGERTYPE: str = name + ".putLargeInteger(" + k2s(key) + ", " + desc.getLargeInteger(key) + ");"; break;                case DescValueType.STRINGTYPE:       str = name + ".putString(" + k2s(key) +          ", \"" + desc.getString(key) + "\");";  break;                case DescValueType.ALIASTYPE:        str = name + ".putPath("   + k2s(key) + ", new File(\"" + desc.getPath(key)   + "\"));"; break;                case DescValueType.UNITDOUBLE:       str = name + ".putUnitDouble(" + k2s(key) + ", " + k2s(desc.getUnitDoubleType(key))  + ", " + desc.getUnitDoubleValue(key)       + ");"; break;                case DescValueType.ENUMERATEDTYPE:   str = name + ".putEnumerated(" + k2s(key) + ", " + k2s(desc.getEnumerationType(key)) + ", " + k2s(desc.getEnumerationValue(key)) + ");"; break;                }            code += "\n" + tab + tab + str;            }        return code;        }    catch (e) { _alert(e); throw(e); }    }

//////////////////////////////////////////////////////////////////////////
function parse_list(list)
    {    try         {        var name = lst_name + (lst_numb?lst_numb:"");        var code = "var " + name + " = new ActionList();";        for (var i = 0; i < list.count; i++)            {            var type = list.getType(i);            var str = "// UNNKOWN TYPE!";             var var_numb;            switch (type)                 {                case DescValueType.OBJECTTYPE:    ++dsc_numb; var_numb = dsc_numb; str = parse_desc(list.getObjectValue(i)) + "\n" + tab + tab + name + ".putObject("    + k2s(list.getObjectType(i)) + ", " + dsc_name + (var_numb?var_numb:"") + ");"; break;                case DescValueType.LISTTYPE:      ++lst_numb; var_numb = lst_numb; str = parse_list(list.getList(i))        + "\n" + tab + tab + name + ".putList("      + lst_name + (var_numb?var_numb:"") + ");"; break;                case DescValueType.REFERENCETYPE: ++ref_numb; var_numb = ref_numb; str = parse_ref(list.getReference(i))    + "\n" + tab + tab + name + ".putReference(" + ref_name + (var_numb?var_numb:"") + ");"; break;                case DescValueType.CLASSTYPE:        str = name + ".putClass(" + k2s(list.getClass(i)) + ");"; break;                case DescValueType.RAWTYPE:          str = name + ".putData("  + dat(desc.getData(i))  + ");"; break;;                 case DescValueType.BOOLEANTYPE:      str = name + ".putBoolean("      + list.getBoolean(i)      + ");"; break;                case DescValueType.INTEGERTYPE:      str = name + ".putInteger("      + list.getInteger(i)      + ");"; break;                case DescValueType.DOUBLETYPE:       str = name + ".putDouble("       + list.getDouble(i)       + ");"; break;                case DescValueType.LARGEINTEGERTYPE: str = name + ".putLargeInteger(" + list.getLargeInteger(i) + ");"; break;                case DescValueType.STRINGTYPE:       str = name + ".putString(" +          "\"" + list.getString(i) + "\");";  break;                case DescValueType.ALIASTYPE:        str = name + ".putPath("   + "new File(\"" + list.getPath(i)   + "\"));"; break;                case DescValueType.UNITDOUBLE:       str = name + ".putUnitDouble(" + k2s(list.getUnitDoubleType(i))  + ", " + list.getUnitDoubleValue(i)       + ");"; break;                case DescValueType.ENUMERATEDTYPE:   str = name + ".putEnumerated(" + k2s(list.getEnumerationType(i)) + ", " + k2s(list.getEnumerationValue(i)) + ");"; break;                }            code += "\n" + tab + tab + str;            }        return code;        }    catch (e) { _alert(e); throw(e); }    }

////////////////////////////////////////////////////////////////////////////////////////////
function parse_ref(ref)
    {    try         {        var name = ref_name + (ref_numb?ref_numb:"");        var code = "var " + name + " = new ActionReference();";        while (1)            {            var ok = true;            try { var type = ref.getForm(); } catch (e) { ok = false; }            if (!ok) break;            var str = "// UNNKOWN TYPE!";             switch (type)                 {                case ReferenceFormType.ENUMERATED: str = name + ".putEnumerated(" + k2s(ref.getDesiredClass()) + ", " + k2s(ref.getEnumeratedType()) + ", " + k2s(ref.getEnumeratedValue()) + ");"; break;                case ReferenceFormType.CLASSTYPE:  str = name + ".putClass("      + k2s(ref.getDesiredClass()) + ");"; break;                case ReferenceFormType.IDENTIFIER: str = name + ".putIdentifier(" + k2s(ref.getDesiredClass()) + ", " + ref.getIdentifier() + ");"; break;                case ReferenceFormType.INDEX:      str = name + ".putIndex("      + k2s(ref.getDesiredClass()) + ", " + ref.getIndex()      + ");"; break;                case ReferenceFormType.OFFSET:     str = name + ".putOffset("     + k2s(ref.getDesiredClass()) + ", " + ref.getOffset()     + ");"; break;                case ReferenceFormType.NAME:       str = name + ".putName("       + k2s(ref.getDesiredClass()) + ", \"" + ref.getName()   + "\");"; break;                case ReferenceFormType.PROPERTY:   str = name + ".putProperty("   + k2s(ref.getDesiredClass()) + ", " + k2s(ref.getProperty())  + ");"; break;                }            code += "\n" + tab + tab + str;            try { ref = ref.getContainer(); } catch (e) { ok = false; }            if (!ok) break;            }        return code;        }    catch (e) { _alert(e); throw(e); }    }

Searching Arrays - indexOf

$
0
0

I was trying to search an array, and on the web it says to use something like this:

 

var tA = ['one','two'];

$.writeln(tA.indexOf ('one'))

 

However, when I try this, I get: tA.indexOf is not a function."  It works with a string variable but not an array.  Is this a bug, or an I doing something wrong?

Copy css don't work in photoshop.

$
0
0

I want to use "copy css" ,but it alert javascript is lose.

Transforms guides into lines

$
0
0

good morning

I'm new to this place

 

 

I would like to know if there is a way to transform the guides into lines

 

 

As in the case

 

 

thank you

 

Schermata 2017-07-20 alle 11.28.00.png

Apply an action to all selected layers

$
0
0

Hy!

 

I wish to do an action i 've made (select a specific zone and deleted it), on every layer i selected.

It can be 2 to 28 layers...

 

I hope you can help me

THX

Learning scripting for Photoshop

$
0
0

Hi all,

 

A few artists that I work with have been asking me a lot about how to learn how to write scripts for Photoshop. I decided to put a full Javascript for Photoshop tutorial series together which may interest anyone asking questions on here. A lot of the questions that are being asked are completely addressed.

 

If anyone is interested, you can check it out at www.photoshopscripting.com.au. The discount code of LRNJS4PS can be used if you want to save 25 percent.

 

I am happy to answer any and all questions for students of these tutorials and you will also gain access to a community reserved for the tutorial members,

 

Thanks

 

James

Viewing all 12244 articles
Browse latest View live


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