Skip to main content
Inspiring
March 28, 2019
Answered

Clear history log of script activities

  • March 28, 2019
  • 8 replies
  • 5550 views

Is it possible to delete all activities from the history log after the script is completed (don't delete the previous user activities)?

Thanks in advance

This topic has been closed for replies.
Correct answer JJMack

Yes I did it the same way using their math way using the document width and height.

I wish Adobe would fix reported acknowledged bugs

It is not just resize selection I may be any transform like transforming a layer size If the is an active selection  and history is suspended  Adobe Scripting back up the document up a history state. Reported years ago. Photoshop: Script bug resize layer back document up one history state | Photoshop Family Customer Community

I seen script posted here the were bitten more than once they were backed up several history states.

// If you delete last line script works properly, but record the history, with last line i got errors 

var startRulerUnits = app.preferences.rulerUnits;   

app.preferences.rulerUnits = Units.CM; 

var backup = app.activeDocument.historyStates.length; 

var box = new Window('dialog', "INFO"); 

var a = ["Employee1", "Employee2", "Employee3"];   

for (var i = 0; i < a.length; i += 1) {   

a["_"+a] = i;   

var c = ["001", "002", "003", "004","005", "006", "007","008", "009", "010"];   

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

c["_"+c] = i;   

box.group = box.add('group', undefined );   

box.group.orientation='row';  

box.group.alignment = 'right';  

box.group.text1 = box.group.add('statictext', undefined, "Employee"); 

box.group = box.group.add("dropdownlist", [25,40,160,60], a); 

box.group1 = box.add('group', undefined );  

box.group1.orientation='row';  

box.group1.alignment = 'right';  

box.group1.text1 = box.group1.add('statictext', undefined, "Iteration"); 

box.group1 = box.group1.add("dropdownlist", [25,40,160,60], c); 

box.group5 = box.add('group', undefined );  

box.group5.orientation='row';   

box.group5.alignment = 'right'; 

box.group5.text1 = box.group5.add('statictext', undefined, "Comments"); 

box.group5 = box.group5.add('edittext', [25,40,160,160],"",{multiline:true, scrollable:false}); 

box.group8 = box.add('group', undefined );  

box.group8.orientation='row';   

box.group8.alignment = 'right'; 

box.group8.text1 = box.group8.add('statictext', undefined, "Duplicate info"); 

box.group8 = box.group8.add("checkbox", undefined, "Yes"); 

var btnGroup = box.add ("group"); 

btnGroup.orientation = "row"; 

var btnOk = btnGroup.add("button", undefined, "OK");   

var btnCancel = btnGroup.add("button", undefined, "Cancel");  

box.center(); 

btnOk.onClick = function() {   

    box.close(1); 

};   

btnCancel.onClick = function() {   

    box.close(0); 

};  

if (box.show() === 1) {  

app.activeDocument.suspendHistory('INFO','main()');  

    } 

function main(){  

 

  var GroupPsdInfo = app.activeDocument.layerSets.add(); 

if(box.group1.selection){  

var it = box.group1.selection.text; 

GroupPsdInfo.name = "INFO _" + it;} 

else { 

    GroupPsdInfo.name = "PSD INFO";}  

var infobg = app.activeDocument.artLayers.add();   

var white = new SolidColor();    

white.rgb["hexValue"] = "ffffff"    

backgroundColor = white;   

var xwidth = app.activeDocument.width.value/app.activeDocument.resolution*5.5;

var yheight = app.activeDocument.height.value/app.activeDocument.resolution*5.5;

var selectedRegion = Array(Array(0,0), Array(xwidth,0), Array(xwidth,yheight), Array(0,yheight));

app.activeDocument.selection.select(selectedRegion);

app.activeDocument.selection.fill(app.backgroundColor) 

/* 

app.activeDocument.selection.selectAll();   

resizeSelection(5.5,5.5);  

function resizeSelection(horizontal, vertical){   

var strtRulerUnits = app.preferences.rulerUnits;   

var strtTypeUnits = app.preferences.typeUnits;   

app.preferences.rulerUnits = Units.CM;   

app.preferences.typeUnits = TypeUnits.PIXELS;   

var SB = activeDocument.selection.bounds;   

var Height = SB[3].value - SB[1].value;   

var Width = SB[2].value - SB[0].value;   

var onePixH = 100/Height;   

var onePixW = 100/Width;   

var newWidth = onePixW * horizontal;   

var newHeight = onePixH * vertical;   

activeDocument.selection.resize( newWidth , newHeight, AnchorPosition.TOPLEFT);   

app.preferences.rulerUnits = strtRulerUnits;   

app.preferences.typeUnits = strtTypeUnits; 

*/

infobg.name = "BG"; 

var col = new SolidColor(); 

col.cmyk.cyan = 0; 

col.cmyk.magenta = 0; 

col.cmyk.yellow = 0; 

col.cmyk.black = 0; 

var str = new SolidColor(); 

str.cmyk.cyan = 100; 

str.cmyk.magenta = 30; 

str.cmyk.yellow = 0; 

str.cmyk.black = 0; 

app.activeDocument.selection.fill(col); 

app.activeDocument.selection.stroke (str,12,StrokeLocation.INSIDE, ColorBlendMode.NORMAL, 100, false);   

activeDocument.selection.deselect();  

infobg.move(GroupPsdInfo,ElementPlacement.INSIDE)  

/* 

*/

if(box.group5.text){ 

var comm = box.group5.text; 

var comments = app.activeDocument.artLayers.add();   

comments.kind = LayerKind.TEXT; 

comments.textItem.contents = "Comments: \r" + box.group5.text.replace(/\n/g, "\r");  

comments.textItem.font = "Helvetica";   

comments.textItem.justification = Justification.LEFT;   

comments.textItem.position = [0.5, 1.2];   

comments.textItem.size = 10; 

comments.move(GroupPsdInfo,ElementPlacement.INSIDE)   

}  

else { 

var comments = app.activeDocument.artLayers.add();   

comments.kind = LayerKind.TEXT; 

comments.textItem.contents = "Comments: /";  

comments.textItem.font = "Helvetica";   

comments.textItem.justification = Justification.LEFT;   

comments.textItem.position = [0.5, 1.2];   

comments.textItem.size = 10; 

comments.move(GroupPsdInfo,ElementPlacement.INSIDE) 

if(box.group.selection){   

var ir = box.group.selection.text; 

var imageRetoucher = app.activeDocument.artLayers.add();   

imageRetoucher.kind = LayerKind.TEXT;   

imageRetoucher.textItem.contents = "Employee: " + ir;   

imageRetoucher.textItem.font = "Helvetica";   

imageRetoucher.textItem.justification = Justification.LEFT;    

imageRetoucher.textItem.position = [0.5, 0.7];    

imageRetoucher.textItem.size = 10; 

imageRetoucher.move(GroupPsdInfo,ElementPlacement.INSIDE)  

else {  

var imageRetoucher = app.activeDocument.artLayers.add();   

imageRetoucher.kind = LayerKind.TEXT;   

imageRetoucher.textItem.contents = "Employee: /";   

imageRetoucher.textItem.font = "Helvetica";   

imageRetoucher.textItem.justification = Justification.LEFT;    

imageRetoucher.textItem.position = [0.5, 0.7];    

imageRetoucher.textItem.size = 10; 

imageRetoucher.move(GroupPsdInfo,ElementPlacement.INSIDE)  

}  

var doc = app.activeDocument; 

var layerParent = doc.activeLayer.parent; 

if ( layerParent !== doc ) doc.activeLayer = layerParent; 

if (activeDocument.activeLayer.typename === 'LayerSet') {app.activeDocument.suspendHistory('closeGroup','closeGroup(activeDocument.activeLayer)');}   

function cTID(s){return charIDToTypeID(s)}   

function sTID(s){return stringIDToTypeID(s)}   

function openAllLayerSets( parent ){   

    for(var setIndex=0;setIndex<parent.layerSets.length;setIndex++){   

        app.activeDocument.activeLayer = parent.layerSets[setIndex].layers[0];   

        openAllLayerSets( parent.layerSets[setIndex]);   

    }   

};    

function closeAllLayerSets(ref) {   

          var layers = ref.layers;   

          var len = layers.length;   

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

                    var layer = layers;   

                    if (layer.typename == 'LayerSet') {closeGroup(layer); var layer = layers; closeAllLayerSets(layer);};   

          }   

}   

function openGroup(layerSet) {   

   var m_activeLayer = activeDocument.activeLayer; 

   var m_Layer_Dummy01 = layerSet.artLayers.add();   

   var m_Layer_Dummy02 = layerSet.artLayers.add();   

   layerSet.layers[1].name = layerSet.layers[1].name;   

   m_Layer_Dummy01.remove();   

   m_Layer_Dummy02.remove();   

   

   activeDocument.activeLayer = m_activeLayer;   

}   

function closeGroup(layerSet) {   

   var m_Name = layerSet.name;   

   var m_Opacity = layerSet.opacity;   

   var m_BlendMode = layerSet.blendMode;   

   var m_LinkedLayers = layerSet.linkedLayers;   

   

   var m_bHasMask = hasLayerMask();   

   if(m_bHasMask) loadSelectionOfMask();    

   if(layerSet.layers.length <= 1) {   

      addLayer();   

      var m_Tmp = activeDocument.activeLayer;   

      m_Tmp.name = "dummy - feel free to remove me";   

      activeDocument.activeLayer = layerSet;   

      ungroup();   

      addToSelection("dummy - feel free to remove me");   

      groupSelected(m_Name);   

   

   } else {   

      activeDocument.activeLayer = layerSet;   

      ungroup();   

      groupSelected(m_Name);   

   }   

   

   

   var m_Closed = activeDocument.activeLayer;   

   m_Closed.opacity = m_Opacity;   

   m_Closed.blendMode = m_BlendMode;   

   

   for(x in m_LinkedLayers) {   

      if(m_LinkedLayers.typename == "LayerSet")   

         activeDocument.activeLayer.link(m_LinkedLayers);   

   }   

   

   if(m_bHasMask) maskFromSelection();   

   

   return m_Closed;   

}    

function ungroup() {   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putEnumerated( cTID( "Lyr " ), cTID( "Ordn" ), cTID( "Trgt" ) );   

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 );   

   

   try {   

      executeAction( sTID( "ungroupLayersEvent" ), m_Dsc01, DialogModes.NO );   

   } catch(e) {}   

}   

function addLayer() {   

   var m_ActiveLayer          =    activeDocument.activeLayer;   

   var m_NewLayer             =    activeDocument.artLayers.add();   

   m_NewLayer.move(m_ActiveLayer, ElementPlacement.PLACEBEFORE);   

   

   return m_NewLayer;   

}    

function hasLayerMask() {   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putEnumerated( sTID( "layer" ), cTID( "Ordn" ), cTID( "Trgt" ));   

   var m_Dsc01= executeActionGet( m_Ref01 );   

   return m_Dsc01.hasKey(cTID('Usrs'));   

}   

function activateLayerMask() {   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putEnumerated( cTID( "Chnl" ), cTID( "Chnl" ), cTID( "Msk " ) );   

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 );   

   

   try {   

      executeAction( cTID( "slct" ), m_Dsc01, DialogModes.NO );   

   } catch(e) {   

      var m_TmpAlpha = new TemporaryAlpha();   

   

      maskFromSelection();   

      activateLayerMask();   

   

      m_TmpAlpha.consume();   

   }   

}   

function deleteMask(makeSelection) {   

   if(makeSelection) {   

      loadSelectionOfMask();   

   }   

   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putEnumerated( cTID( "Chnl" ), cTID( "Ordn" ), cTID( "Trgt" ) );   

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 );   

   

   try {   

      executeAction( cTID( "Dlt " ), m_Dsc01, DialogModes.NO );   

   } catch(e) {}   

}    

function selectLayerMask() {   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   

   

   m_Ref01.putEnumerated(cTID("Chnl"), cTID("Chnl"), cTID("Msk "));   

   m_Dsc01.putReference(cTID("null"), m_Ref01);   

   m_Dsc01.putBoolean(cTID("MkVs"), false );   

   

   

   try {   

      executeAction(cTID("slct"), m_Dsc01, DialogModes.NO );   

   } catch(e) {}   

}   

function loadSelectionOfMask() {   

   selectLayerMask();   

   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putProperty( cTID( "Chnl" ), cTID( "fsel" ) );   

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 );   

   var m_Ref02 = new ActionReference();   

   m_Ref02.putEnumerated( cTID( "Chnl" ), cTID( "Ordn" ), cTID( "Trgt" ) );   

   m_Dsc01.putReference( cTID( "T   " ), m_Ref02 );   

   

   try {   

      executeAction( cTID( "setd" ), m_Dsc01, DialogModes.NO );   

   } catch(e) {}   

}    

function maskFromSelection() {   

   if(!hasLayerMask()) {   

      var m_Dsc01 = new ActionDescriptor();   

      m_Dsc01.putClass( cTID( "Nw  " ), cTID( "Chnl" ) );   

      var m_Ref01 = new ActionReference();   

      m_Ref01.putEnumerated( cTID( "Chnl" ), cTID( "Chnl" ), cTID( "Msk " ) );   

      m_Dsc01.putReference( cTID( "At  " ), m_Ref01 );   

      m_Dsc01.putEnumerated( cTID( "Usng" ), cTID( "UsrM" ), cTID( "RvlS" ) );   

   

      try {   

         executeAction( cTID( "Mk  " ), m_Dsc01, DialogModes.NO );   

      } catch(e) {   

         activeDocument.selection.selectAll();   

         maskFromSelection();   

      }   

   } else {   

      if(confirm("Delete existing mask?", true, "Warning")) {   

         activateLayerMask();   

         deleteMask();   

      }   

   }   

function groupSelected(name) {   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putClass( sTID( "layerSection" ) );   

   m_Dsc01.putReference(  cTID( "null" ), m_Ref01 );   

   var m_Ref02 = new ActionReference();   

   m_Ref02.putEnumerated( cTID( "Lyr " ), cTID( "Ordn" ), cTID( "Trgt" ) );   

   m_Dsc01.putReference( cTID( "From" ), m_Ref02 );   

   var m_Dsc02 = new ActionDescriptor();   

   m_Dsc02.putString( cTID( "Nm  " ), name);   

   m_Dsc01.putObject( cTID( "Usng" ), sTID( "layerSection" ), m_Dsc02 );   

   executeAction( cTID( "Mk  " ), m_Dsc01, DialogModes.NO );   

   

   return activeDocument.activeLayer;   

}   

function addToSelection(layerName) {   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putName( cTID( "Lyr " ), layerName );   

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 );   

   m_Dsc01.putEnumerated( sTID( "selectionModifier" ), sTID( "selectionModifierType" ), sTID( "addToSelection" ) );   

   m_Dsc01.putBoolean( cTID( "MkVs" ), false );   

   

   try {   

      executeAction( cTID( "slct" ), m_Dsc01, DialogModes.NO );   

   } catch(e) {}   

}   

function TemporaryAlpha() {   

   activeDocument.selection.store((this.alpha = activeDocument.channels.add()));   

   activeDocument.selection.deselect();   

   

   this.consume = function() {   

      activeDocument.selection.load(this.alpha);   

      this.alpha.remove();   

   }   

}   

layerColour("yellow");    

function layerColour(colour) {   

    switch (colour.toLocaleLowerCase()){   

        case 'red': colour = 'Rd  '; break;   

        case 'orange' : colour = 'Orng'; break;   

        case 'yellow' : colour = 'Ylw '; break;   

        case 'yellow' : colour = 'Ylw '; break;   

        case 'green' : colour = 'Grn '; break;   

        case 'blue' : colour = 'Bl  '; break;   

        case 'violet' : colour = 'Vlt '; break;   

        case 'gray' : colour = 'Gry '; break;   

        case 'none' : colour = 'None'; break;   

        default : colour = 'None'; break;   

        }   

    var desc = new ActionDescriptor();   

        var ref = new ActionReference();   

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

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

        var desc2 = new ActionDescriptor();   

        desc2.putEnumerated( charIDToTypeID('Clr '), charIDToTypeID('Clr '), charIDToTypeID(colour) );   

    desc.putObject( charIDToTypeID('T   '), charIDToTypeID('Lyr '), desc2 );   

    executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );   

};  

if(box.group8.value){   

if( app.documents.length > 0 ){ 

    duplicateToAll(); 

function duplicateToAll(){ 

    docs = app.documents; 

    curDoc = app.activeDocument; 

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

        if(curDoc != docs){ 

        var curLayer; 

        try { curLayer = docs.activeLayer; } catch(e) {} 

        curDoc.activeLayer.duplicate(docs,ElementPlacement.PLACEATBEGINNING); 

        } 

        app.activeDocument = curDoc; 

    } 

function cTID(s){return charIDToTypeID(s)} 

function sTID(s){return stringIDToTypeID(s)} 

box.close(); 

8 replies

JJMack
Community Expert
Community Expert
April 2, 2019

You need to calulate what size you need and use that value in place or the constant 5.5.  You can not  use a transform when there is an active selection.  You can use a transform to resize a layer when there is no active selection when History states are suspended.  For some reason unknown to me When history is suspend and there is an active selection a Transform will back up your document a history state the layer you added in the script is no more. You document is in a state before the layer was added. Its a know bug Adoce doe not care to fix.

So calulate the layer size you need and fill that area or calulate the percentage the layer needs to be resized.  And use a function to do the layer resize that does a deselect before using resize  to transform the layer size.

JJMack
milevicAuthor
Inspiring
April 2, 2019

Thanks a lot JJMack

I just need to resolve problem with a white bg layer, now i dont have fix layer size 5.5X5.cm, layer size depend of document canvas size?

milevicAuthor
Inspiring
April 1, 2019

// If you delete last line script works properly, but record the history, with last line i got errors

var startRulerUnits = app.preferences.rulerUnits; 

app.preferences.rulerUnits = Units.CM;

var backup = app.activeDocument.historyStates.length;

var box = new Window('dialog', "INFO");

var a = ["Employee1", "Employee2", "Employee3"]; 

for (var i = 0; i < a.length; i += 1) { 

a["_"+a] = i; 

}

var c = ["001", "002", "003", "004","005", "006", "007","008", "009", "010"]; 

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

c["_"+c] = i; 

}

box.group = box.add('group', undefined ); 

box.group.orientation='row';

box.group.alignment = 'right';

box.group.text1 = box.group.add('statictext', undefined, "Employee");

box.group = box.group.add("dropdownlist", [25,40,160,60], a);

box.group1 = box.add('group', undefined );

box.group1.orientation='row';

box.group1.alignment = 'right';

box.group1.text1 = box.group1.add('statictext', undefined, "Iteration");

box.group1 = box.group1.add("dropdownlist", [25,40,160,60], c);

box.group5 = box.add('group', undefined );

box.group5.orientation='row'; 

box.group5.alignment = 'right';

box.group5.text1 = box.group5.add('statictext', undefined, "Comments");

box.group5 = box.group5.add('edittext', [25,40,160,160],"",{multiline:true, scrollable:false});

box.group8 = box.add('group', undefined );

box.group8.orientation='row'; 

box.group8.alignment = 'right';

box.group8.text1 = box.group8.add('statictext', undefined, "Duplicate info");

box.group8 = box.group8.add("checkbox", undefined, "Yes");

var btnGroup = box.add ("group");

btnGroup.orientation = "row";

var btnOk = btnGroup.add("button", undefined, "OK"); 

var btnCancel = btnGroup.add("button", undefined, "Cancel");

box.center();

btnOk.onClick = function() { 

    box.close(1);

}; 

btnCancel.onClick = function() { 

    box.close(0);

};

if (box.show() === 1) {

main()

    }

function main(){

  var GroupPsdInfo = app.activeDocument.layerSets.add();

if(box.group1.selection){

var it = box.group1.selection.text;

GroupPsdInfo.name = "INFO _" + it;}

else {

    GroupPsdInfo.name = "PSD INFO";}

var infobg = app.activeDocument.artLayers.add(); 

var white = new SolidColor();  

white.rgb["hexValue"] = "ffffff"  

backgroundColor = white; 

app.activeDocument.selection.fill(app.backgroundColor) 

app.activeDocument.selection.selectAll(); 

resizeSelection(5.5,5.5);

function resizeSelection(horizontal, vertical){ 

var strtRulerUnits = app.preferences.rulerUnits; 

var strtTypeUnits = app.preferences.typeUnits; 

app.preferences.rulerUnits = Units.CM; 

app.preferences.typeUnits = TypeUnits.PIXELS; 

var SB = activeDocument.selection.bounds; 

var Height = SB[3].value - SB[1].value; 

var Width = SB[2].value - SB[0].value; 

var onePixH = 100/Height; 

var onePixW = 100/Width; 

var newWidth = onePixW * horizontal; 

var newHeight = onePixH * vertical; 

activeDocument.selection.resize( newWidth , newHeight, AnchorPosition.TOPLEFT); 

app.preferences.rulerUnits = strtRulerUnits; 

app.preferences.typeUnits = strtTypeUnits;

infobg.name = "BG";

var col = new SolidColor();

col.cmyk.cyan = 0;

col.cmyk.magenta = 0;

col.cmyk.yellow = 0;

col.cmyk.black = 0;

var str = new SolidColor();

str.cmyk.cyan = 100;

str.cmyk.magenta = 30;

str.cmyk.yellow = 0;

str.cmyk.black = 0;

app.activeDocument.selection.fill(col);

app.activeDocument.selection.stroke (str,12,StrokeLocation.INSIDE, ColorBlendMode.NORMAL, 100, false); 

activeDocument.selection.deselect();

infobg.move(GroupPsdInfo,ElementPlacement.INSIDE)  

}

if(box.group5.text){

var comm = box.group5.text;

var comments = app.activeDocument.artLayers.add(); 

comments.kind = LayerKind.TEXT;

comments.textItem.contents = "Comments: \r" + box.group5.text.replace(/\n/g, "\r");

comments.textItem.font = "Helvetica"; 

comments.textItem.justification = Justification.LEFT; 

comments.textItem.position = [0.5, 1.2]; 

comments.textItem.size = 10;

comments.move(GroupPsdInfo,ElementPlacement.INSIDE) 

}

else {

var comments = app.activeDocument.artLayers.add(); 

comments.kind = LayerKind.TEXT;

comments.textItem.contents = "Comments: /";

comments.textItem.font = "Helvetica"; 

comments.textItem.justification = Justification.LEFT; 

comments.textItem.position = [0.5, 1.2]; 

comments.textItem.size = 10;

comments.move(GroupPsdInfo,ElementPlacement.INSIDE)

}

if(box.group.selection){ 

var ir = box.group.selection.text;

var imageRetoucher = app.activeDocument.artLayers.add(); 

imageRetoucher.kind = LayerKind.TEXT; 

imageRetoucher.textItem.contents = "Employee: " + ir; 

imageRetoucher.textItem.font = "Helvetica"; 

imageRetoucher.textItem.justification = Justification.LEFT;  

imageRetoucher.textItem.position = [0.5, 0.7];  

imageRetoucher.textItem.size = 10;

imageRetoucher.move(GroupPsdInfo,ElementPlacement.INSIDE)

}

else {

var imageRetoucher = app.activeDocument.artLayers.add(); 

imageRetoucher.kind = LayerKind.TEXT; 

imageRetoucher.textItem.contents = "Employee: /"; 

imageRetoucher.textItem.font = "Helvetica"; 

imageRetoucher.textItem.justification = Justification.LEFT;  

imageRetoucher.textItem.position = [0.5, 0.7];  

imageRetoucher.textItem.size = 10;

imageRetoucher.move(GroupPsdInfo,ElementPlacement.INSIDE)

}

var doc = app.activeDocument;

var layerParent = doc.activeLayer.parent;

if ( layerParent !== doc ) doc.activeLayer = layerParent;

if (activeDocument.activeLayer.typename === 'LayerSet') {app.activeDocument.suspendHistory('closeGroup','closeGroup(activeDocument.activeLayer)');} 

function cTID(s){return charIDToTypeID(s)} 

function sTID(s){return stringIDToTypeID(s)} 

function openAllLayerSets( parent ){ 

    for(var setIndex=0;setIndex<parent.layerSets.length;setIndex++){ 

        app.activeDocument.activeLayer = parent.layerSets[setIndex].layers[0]; 

        openAllLayerSets( parent.layerSets[setIndex]); 

    } 

};  

function closeAllLayerSets(ref) { 

          var layers = ref.layers; 

          var len = layers.length; 

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

                    var layer = layers

                    if (layer.typename == 'LayerSet') {closeGroup(layer); var layer = layers; closeAllLayerSets(layer);}; 

          } 

function openGroup(layerSet) { 

   var m_activeLayer = activeDocument.activeLayer;

   var m_Layer_Dummy01 = layerSet.artLayers.add(); 

   var m_Layer_Dummy02 = layerSet.artLayers.add(); 

   layerSet.layers[1].name = layerSet.layers[1].name; 

   m_Layer_Dummy01.remove(); 

   m_Layer_Dummy02.remove(); 

 

   activeDocument.activeLayer = m_activeLayer; 

function closeGroup(layerSet) { 

   var m_Name = layerSet.name; 

   var m_Opacity = layerSet.opacity; 

   var m_BlendMode = layerSet.blendMode; 

   var m_LinkedLayers = layerSet.linkedLayers; 

 

   var m_bHasMask = hasLayerMask(); 

   if(m_bHasMask) loadSelectionOfMask();  

   if(layerSet.layers.length <= 1) { 

      addLayer(); 

      var m_Tmp = activeDocument.activeLayer; 

      m_Tmp.name = "dummy - feel free to remove me"; 

      activeDocument.activeLayer = layerSet; 

      ungroup(); 

      addToSelection("dummy - feel free to remove me"); 

      groupSelected(m_Name); 

 

   } else { 

      activeDocument.activeLayer = layerSet; 

      ungroup(); 

      groupSelected(m_Name); 

   } 

 

 

   var m_Closed = activeDocument.activeLayer; 

   m_Closed.opacity = m_Opacity; 

   m_Closed.blendMode = m_BlendMode; 

 

   for(x in m_LinkedLayers) { 

      if(m_LinkedLayers.typename == "LayerSet") 

         activeDocument.activeLayer.link(m_LinkedLayers); 

   } 

 

   if(m_bHasMask) maskFromSelection(); 

 

   return m_Closed; 

}  

function ungroup() { 

   var m_Dsc01 = new ActionDescriptor(); 

   var m_Ref01 = new ActionReference(); 

   m_Ref01.putEnumerated( cTID( "Lyr " ), cTID( "Ordn" ), cTID( "Trgt" ) ); 

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 ); 

 

   try { 

      executeAction( sTID( "ungroupLayersEvent" ), m_Dsc01, DialogModes.NO ); 

   } catch(e) {} 

function addLayer() { 

   var m_ActiveLayer          =    activeDocument.activeLayer; 

   var m_NewLayer             =    activeDocument.artLayers.add(); 

   m_NewLayer.move(m_ActiveLayer, ElementPlacement.PLACEBEFORE); 

 

   return m_NewLayer; 

}  

function hasLayerMask() { 

   var m_Ref01 = new ActionReference(); 

   m_Ref01.putEnumerated( sTID( "layer" ), cTID( "Ordn" ), cTID( "Trgt" )); 

   var m_Dsc01= executeActionGet( m_Ref01 ); 

   return m_Dsc01.hasKey(cTID('Usrs')); 

function activateLayerMask() { 

   var m_Dsc01 = new ActionDescriptor(); 

   var m_Ref01 = new ActionReference(); 

   m_Ref01.putEnumerated( cTID( "Chnl" ), cTID( "Chnl" ), cTID( "Msk " ) ); 

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 ); 

 

   try { 

      executeAction( cTID( "slct" ), m_Dsc01, DialogModes.NO ); 

   } catch(e) { 

      var m_TmpAlpha = new TemporaryAlpha(); 

 

      maskFromSelection(); 

      activateLayerMask(); 

 

      m_TmpAlpha.consume(); 

   } 

function deleteMask(makeSelection) { 

   if(makeSelection) { 

      loadSelectionOfMask(); 

   } 

 

   var m_Dsc01 = new ActionDescriptor(); 

   var m_Ref01 = new ActionReference(); 

   m_Ref01.putEnumerated( cTID( "Chnl" ), cTID( "Ordn" ), cTID( "Trgt" ) ); 

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 ); 

 

   try { 

      executeAction( cTID( "Dlt " ), m_Dsc01, DialogModes.NO ); 

   } catch(e) {} 

}  

function selectLayerMask() { 

   var m_Dsc01 = new ActionDescriptor(); 

   var m_Ref01 = new ActionReference(); 

 

 

   m_Ref01.putEnumerated(cTID("Chnl"), cTID("Chnl"), cTID("Msk ")); 

   m_Dsc01.putReference(cTID("null"), m_Ref01); 

   m_Dsc01.putBoolean(cTID("MkVs"), false ); 

 

 

   try { 

      executeAction(cTID("slct"), m_Dsc01, DialogModes.NO ); 

   } catch(e) {} 

function loadSelectionOfMask() { 

   selectLayerMask(); 

 

   var m_Dsc01 = new ActionDescriptor(); 

   var m_Ref01 = new ActionReference(); 

   m_Ref01.putProperty( cTID( "Chnl" ), cTID( "fsel" ) ); 

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 ); 

   var m_Ref02 = new ActionReference(); 

   m_Ref02.putEnumerated( cTID( "Chnl" ), cTID( "Ordn" ), cTID( "Trgt" ) ); 

   m_Dsc01.putReference( cTID( "T   " ), m_Ref02 ); 

 

   try { 

      executeAction( cTID( "setd" ), m_Dsc01, DialogModes.NO ); 

   } catch(e) {} 

}  

function maskFromSelection() { 

   if(!hasLayerMask()) { 

      var m_Dsc01 = new ActionDescriptor(); 

      m_Dsc01.putClass( cTID( "Nw  " ), cTID( "Chnl" ) ); 

      var m_Ref01 = new ActionReference(); 

      m_Ref01.putEnumerated( cTID( "Chnl" ), cTID( "Chnl" ), cTID( "Msk " ) ); 

      m_Dsc01.putReference( cTID( "At  " ), m_Ref01 ); 

      m_Dsc01.putEnumerated( cTID( "Usng" ), cTID( "UsrM" ), cTID( "RvlS" ) ); 

 

      try { 

         executeAction( cTID( "Mk  " ), m_Dsc01, DialogModes.NO ); 

      } catch(e) { 

         activeDocument.selection.selectAll(); 

         maskFromSelection(); 

      } 

   } else { 

      if(confirm("Delete existing mask?", true, "Warning")) { 

         activateLayerMask(); 

         deleteMask(); 

      } 

   } 

}

function groupSelected(name) { 

   var m_Dsc01 = new ActionDescriptor(); 

   var m_Ref01 = new ActionReference(); 

   m_Ref01.putClass( sTID( "layerSection" ) ); 

   m_Dsc01.putReference(  cTID( "null" ), m_Ref01 ); 

   var m_Ref02 = new ActionReference(); 

   m_Ref02.putEnumerated( cTID( "Lyr " ), cTID( "Ordn" ), cTID( "Trgt" ) ); 

   m_Dsc01.putReference( cTID( "From" ), m_Ref02 ); 

   var m_Dsc02 = new ActionDescriptor(); 

   m_Dsc02.putString( cTID( "Nm  " ), name); 

   m_Dsc01.putObject( cTID( "Usng" ), sTID( "layerSection" ), m_Dsc02 ); 

   executeAction( cTID( "Mk  " ), m_Dsc01, DialogModes.NO ); 

 

   return activeDocument.activeLayer; 

function addToSelection(layerName) { 

   var m_Dsc01 = new ActionDescriptor(); 

   var m_Ref01 = new ActionReference(); 

   m_Ref01.putName( cTID( "Lyr " ), layerName ); 

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 ); 

   m_Dsc01.putEnumerated( sTID( "selectionModifier" ), sTID( "selectionModifierType" ), sTID( "addToSelection" ) ); 

   m_Dsc01.putBoolean( cTID( "MkVs" ), false ); 

 

   try { 

      executeAction( cTID( "slct" ), m_Dsc01, DialogModes.NO ); 

   } catch(e) {} 

function TemporaryAlpha() { 

   activeDocument.selection.store((this.alpha = activeDocument.channels.add())); 

   activeDocument.selection.deselect(); 

 

   this.consume = function() { 

      activeDocument.selection.load(this.alpha); 

      this.alpha.remove(); 

   } 

layerColour("yellow");  

function layerColour(colour) { 

    switch (colour.toLocaleLowerCase()){ 

        case 'red': colour = 'Rd  '; break; 

        case 'orange' : colour = 'Orng'; break; 

        case 'yellow' : colour = 'Ylw '; break; 

        case 'yellow' : colour = 'Ylw '; break; 

        case 'green' : colour = 'Grn '; break; 

        case 'blue' : colour = 'Bl  '; break; 

        case 'violet' : colour = 'Vlt '; break; 

        case 'gray' : colour = 'Gry '; break; 

        case 'none' : colour = 'None'; break; 

        default : colour = 'None'; break; 

        } 

    var desc = new ActionDescriptor(); 

        var ref = new ActionReference(); 

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

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

        var desc2 = new ActionDescriptor(); 

        desc2.putEnumerated( charIDToTypeID('Clr '), charIDToTypeID('Clr '), charIDToTypeID(colour) ); 

    desc.putObject( charIDToTypeID('T   '), charIDToTypeID('Lyr '), desc2 ); 

    executeAction( charIDToTypeID('setd'), desc, DialogModes.NO ); 

};

if(box.group8.value){ 

if( app.documents.length > 0 ){

    duplicateToAll();

}

function duplicateToAll(){

    docs = app.documents;

    curDoc = app.activeDocument;

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

        if(curDoc != docs){

        var curLayer;

        try { curLayer = docs.activeLayer; } catch(e) {}

        curDoc.activeLayer.duplicate(docs,ElementPlacement.PLACEATBEGINNING);

        }

        app.activeDocument = curDoc;

    }

}

function cTID(s){return charIDToTypeID(s)}

function sTID(s){return stringIDToTypeID(s)}

}

}

box.close();

app.activeDocument.suspendHistory('INFO','main()'); 

Legend
April 1, 2019

You hit the bug with selection.resize and selection.resizeBoundary when using suspendHistory.

Very tricky script. Does not work with CS6 at all.
I changed the code. It works there and there with suspendHistory.


Check.

var startRulerUnits = app.preferences.rulerUnits;   

app.preferences.rulerUnits = Units.CM; 

var backup = app.activeDocument.historyStates.length; 

var box = new Window('dialog', "INFO"); 

var a = ["Employee1", "Employee2", "Employee3"];   

for (var i = 0; i < a.length; i += 1) {   

a["_"+a] = i;   

var c = ["001", "002", "003", "004","005", "006", "007","008", "009", "010"];   

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

c["_"+c] = i;   

box.group = box.add('group', undefined );   

box.group.orientation='row';  

box.group.alignment = 'right';  

box.group.text1 = box.group.add('statictext', undefined, "Employee"); 

box.group = box.group.add("dropdownlist", [25,40,160,60], a); 

box.group1 = box.add('group', undefined );  

box.group1.orientation='row';  

box.group1.alignment = 'right';  

box.group1.text1 = box.group1.add('statictext', undefined, "Iteration"); 

box.group1 = box.group1.add("dropdownlist", [25,40,160,60], c); 

box.group5 = box.add('group', undefined );  

box.group5.orientation='row';   

box.group5.alignment = 'right'; 

box.group5.text1 = box.group5.add('statictext', undefined, "Comments"); 

box.group5 = box.group5.add('edittext', [25,40,160,160],"",{multiline:true, scrollable:false}); 

box.group8 = box.add('group', undefined );  

box.group8.orientation='row';   

box.group8.alignment = 'right'; 

box.group8.text1 = box.group8.add('statictext', undefined, "Duplicate info"); 

box.group8 = box.group8.add("checkbox", undefined, "Yes"); 

var btnGroup = box.add ("group"); 

btnGroup.orientation = "row"; 

var btnOk = btnGroup.add("button", undefined, "OK");   

var btnCancel = btnGroup.add("button", undefined, "Cancel");  

box.center(); 

btnOk.onClick = function() {   

    box.close(1); 

};   

btnCancel.onClick = function() {   

    box.close(0); 

};  

if (box.show() === 1) {  

app.activeDocument.suspendHistory('INFO','main()');   

    } 

function main(){  

  var GroupPsdInfo = app.activeDocument.layerSets.add(); 

if(box.group1.selection){  

var it = box.group1.selection.text; 

GroupPsdInfo.name = "INFO _" + it;} 

else { 

    GroupPsdInfo.name = "PSD INFO";}  

var infobg = app.activeDocument.artLayers.add();   

var white = new SolidColor();    

white.rgb["hexValue"] = "ffffff"    

backgroundColor = white;

    var w = 5.5*activeDocument.resolution/2.54;                                               // new code

    var h = 5.5*activeDocument.resolution/2.54;                                               // new code

    app.activeDocument.selection.select([[0,0],[w,0],[w,h],[0,h]], SelectionType.REPLACE);    // new code

    app.activeDocument.selection.fill(app.backgroundColor)                                    // new code

    //app.activeDocument.selection.fill(app.backgroundColor)                                  // removed

    //app.activeDocument.selection.selectAll();                                               // removed

    //resizeSelection(5.5,5.5);                                                               // removed

    //function resizeSelection(horizontal, vertical){                                         // removed

    //var strtRulerUnits = app.preferences.rulerUnits;                                        // removed

    //var strtTypeUnits = app.preferences.typeUnits;                                          // removed

    //app.preferences.rulerUnits = Units.CM;                                                  // removed

    //app.preferences.typeUnits = TypeUnits.PIXELS;                                           // removed

    //var SB = activeDocument.selection.bounds;                                               // removed

    //var Height = SB[3].value - SB[1].value;                                                 // removed

    //var Width = SB[2].value - SB[0].value;                                                  // removed

    //var onePixH = 100/Height;                                                               // removed

    //var onePixW = 100/Width;                                                                // removed

    //var newWidth = onePixW * horizontal;                                                    // removed

    //var newHeight = onePixH * vertical;                                                     // removed

    //activeDocument.selection.resize( newWidth , newHeight, AnchorPosition.TOPLEFT);         // removed

    //app.preferences.rulerUnits = strtRulerUnits;                                            // removed

    //app.preferences.typeUnits = strtTypeUnits;                                              // removed

infobg.name = "BG"; 

var col = new SolidColor(); 

col.cmyk.cyan = 0; 

col.cmyk.magenta = 0; 

col.cmyk.yellow = 0; 

col.cmyk.black = 0; 

var str = new SolidColor(); 

str.cmyk.cyan = 100; 

str.cmyk.magenta = 30; 

str.cmyk.yellow = 0; 

str.cmyk.black = 0; 

app.activeDocument.selection.fill(col); 

app.activeDocument.selection.stroke (str,12,StrokeLocation.INSIDE, ColorBlendMode.NORMAL, 100, false);   

activeDocument.selection.deselect();  

infobg.move(GroupPsdInfo,ElementPlacement.INSIDE)    

    //}                                                                                       // removed

if(box.group5.text){ 

var comm = box.group5.text; 

var comments = app.activeDocument.artLayers.add();   

comments.kind = LayerKind.TEXT; 

comments.textItem.contents = "Comments: \r" + box.group5.text.replace(/\n/g, "\r");  

comments.textItem.font = "Helvetica";   

comments.textItem.justification = Justification.LEFT;   

comments.textItem.position = [0.5, 1.2];   

comments.textItem.size = 10; 

comments.move(GroupPsdInfo,ElementPlacement.INSIDE)   

}  

else { 

var comments = app.activeDocument.artLayers.add();   

comments.kind = LayerKind.TEXT; 

comments.textItem.contents = "Comments: /";  

comments.textItem.font = "Helvetica";   

comments.textItem.justification = Justification.LEFT;   

comments.textItem.position = [0.5, 1.2];   

comments.textItem.size = 10; 

comments.move(GroupPsdInfo,ElementPlacement.INSIDE) 

if(box.group.selection){   

var ir = box.group.selection.text; 

var imageRetoucher = app.activeDocument.artLayers.add();   

imageRetoucher.kind = LayerKind.TEXT;   

imageRetoucher.textItem.contents = "Employee: " + ir;   

imageRetoucher.textItem.font = "Helvetica";   

imageRetoucher.textItem.justification = Justification.LEFT;    

imageRetoucher.textItem.position = [0.5, 0.7];    

imageRetoucher.textItem.size = 10; 

imageRetoucher.move(GroupPsdInfo,ElementPlacement.INSIDE)  

else {  

var imageRetoucher = app.activeDocument.artLayers.add();   

imageRetoucher.kind = LayerKind.TEXT;   

imageRetoucher.textItem.contents = "Employee: /";   

imageRetoucher.textItem.font = "Helvetica";   

imageRetoucher.textItem.justification = Justification.LEFT;    

imageRetoucher.textItem.position = [0.5, 0.7];    

imageRetoucher.textItem.size = 10; 

imageRetoucher.move(GroupPsdInfo,ElementPlacement.INSIDE)  

}  

var doc = app.activeDocument; 

var layerParent = doc.activeLayer.parent; 

if ( layerParent !== doc ) doc.activeLayer = layerParent; 

if (activeDocument.activeLayer.typename === 'LayerSet') {app.activeDocument.suspendHistory('closeGroup','closeGroup(activeDocument.activeLayer)');}   

function cTID(s){return charIDToTypeID(s)}   

function sTID(s){return stringIDToTypeID(s)}   

function openAllLayerSets( parent ){   

    for(var setIndex=0;setIndex<parent.layerSets.length;setIndex++){   

        app.activeDocument.activeLayer = parent.layerSets[setIndex].layers[0];   

        openAllLayerSets( parent.layerSets[setIndex]);   

    }   

};    

function closeAllLayerSets(ref) {   

          var layers = ref.layers;   

          var len = layers.length;   

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

                    var layer = layers;   

                    if (layer.typename == 'LayerSet') {closeGroup(layer); var layer = layers; closeAllLayerSets(layer);};   

          }   

}   

function openGroup(layerSet) {   

   var m_activeLayer = activeDocument.activeLayer; 

   var m_Layer_Dummy01 = layerSet.artLayers.add();   

   var m_Layer_Dummy02 = layerSet.artLayers.add();   

   layerSet.layers[1].name = layerSet.layers[1].name;   

   m_Layer_Dummy01.remove();   

   m_Layer_Dummy02.remove();   

   activeDocument.activeLayer = m_activeLayer;   

}   

function closeGroup(layerSet) {   

   var m_Name = layerSet.name;   

   var m_Opacity = layerSet.opacity;   

   var m_BlendMode = layerSet.blendMode;   

   var m_LinkedLayers = layerSet.linkedLayers;   

   var m_bHasMask = hasLayerMask();   

   if(m_bHasMask) loadSelectionOfMask();    

   if(layerSet.layers.length <= 1) {   

      addLayer();   

      var m_Tmp = activeDocument.activeLayer;   

      m_Tmp.name = "dummy - feel free to remove me";   

      activeDocument.activeLayer = layerSet;   

      ungroup();   

      addToSelection("dummy - feel free to remove me");   

      groupSelected(m_Name);   

   } else {   

      activeDocument.activeLayer = layerSet;   

      ungroup();   

      groupSelected(m_Name);   

   }   

   var m_Closed = activeDocument.activeLayer;   

   m_Closed.opacity = m_Opacity;   

   m_Closed.blendMode = m_BlendMode;   

   for(x in m_LinkedLayers) {   

      if(m_LinkedLayers.typename == "LayerSet")   

         activeDocument.activeLayer.link(m_LinkedLayers);   

   }   

   if(m_bHasMask) maskFromSelection();   

   return m_Closed;   

}    

function ungroup() {   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putEnumerated( cTID( "Lyr " ), cTID( "Ordn" ), cTID( "Trgt" ) );   

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 );   

   try {   

      executeAction( sTID( "ungroupLayersEvent" ), m_Dsc01, DialogModes.NO );   

   } catch(e) {}   

}   

function addLayer() {   

   var m_ActiveLayer          =    activeDocument.activeLayer;   

   var m_NewLayer             =    activeDocument.artLayers.add();   

   m_NewLayer.move(m_ActiveLayer, ElementPlacement.PLACEBEFORE);   

   return m_NewLayer;   

}    

function hasLayerMask() {   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putEnumerated( sTID( "layer" ), cTID( "Ordn" ), cTID( "Trgt" ));   

   var m_Dsc01= executeActionGet( m_Ref01 );   

   return m_Dsc01.hasKey(cTID('Usrs'));   

}   

function activateLayerMask() {   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putEnumerated( cTID( "Chnl" ), cTID( "Chnl" ), cTID( "Msk " ) );   

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 );   

   try {   

      executeAction( cTID( "slct" ), m_Dsc01, DialogModes.NO );   

   } catch(e) {   

      var m_TmpAlpha = new TemporaryAlpha();   

      maskFromSelection();   

      activateLayerMask();   

      m_TmpAlpha.consume();   

   }   

}   

function deleteMask(makeSelection) {   

   if(makeSelection) {   

      loadSelectionOfMask();   

   }   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putEnumerated( cTID( "Chnl" ), cTID( "Ordn" ), cTID( "Trgt" ) );   

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 );   

   try {   

      executeAction( cTID( "Dlt " ), m_Dsc01, DialogModes.NO );   

   } catch(e) {}   

}    

function selectLayerMask() {   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putEnumerated(cTID("Chnl"), cTID("Chnl"), cTID("Msk "));   

   m_Dsc01.putReference(cTID("null"), m_Ref01);   

   m_Dsc01.putBoolean(cTID("MkVs"), false );   

   try {   

      executeAction(cTID("slct"), m_Dsc01, DialogModes.NO );   

   } catch(e) {}   

}   

function loadSelectionOfMask() {   

   selectLayerMask();   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putProperty( cTID( "Chnl" ), cTID( "fsel" ) );   

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 );   

   var m_Ref02 = new ActionReference();   

   m_Ref02.putEnumerated( cTID( "Chnl" ), cTID( "Ordn" ), cTID( "Trgt" ) );   

   m_Dsc01.putReference( cTID( "T   " ), m_Ref02 );   

   try {   

      executeAction( cTID( "setd" ), m_Dsc01, DialogModes.NO );   

   } catch(e) {}   

}    

function maskFromSelection() {   

   if(!hasLayerMask()) {   

      var m_Dsc01 = new ActionDescriptor();   

      m_Dsc01.putClass( cTID( "Nw  " ), cTID( "Chnl" ) );   

      var m_Ref01 = new ActionReference();   

      m_Ref01.putEnumerated( cTID( "Chnl" ), cTID( "Chnl" ), cTID( "Msk " ) );   

      m_Dsc01.putReference( cTID( "At  " ), m_Ref01 );   

      m_Dsc01.putEnumerated( cTID( "Usng" ), cTID( "UsrM" ), cTID( "RvlS" ) );   

      try {   

         executeAction( cTID( "Mk  " ), m_Dsc01, DialogModes.NO );   

      } catch(e) {   

         activeDocument.selection.selectAll();   

         maskFromSelection();   

      }   

   } else {   

      if(confirm("Delete existing mask?", true, "Warning")) {   

         activateLayerMask();   

         deleteMask();   

      }   

   }   

function groupSelected(name) {   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putClass( sTID( "layerSection" ) );   

   m_Dsc01.putReference(  cTID( "null" ), m_Ref01 );   

   var m_Ref02 = new ActionReference();   

   m_Ref02.putEnumerated( cTID( "Lyr " ), cTID( "Ordn" ), cTID( "Trgt" ) );   

   m_Dsc01.putReference( cTID( "From" ), m_Ref02 );   

   var m_Dsc02 = new ActionDescriptor();   

   m_Dsc02.putString( cTID( "Nm  " ), name);   

   m_Dsc01.putObject( cTID( "Usng" ), sTID( "layerSection" ), m_Dsc02 );   

   executeAction( cTID( "Mk  " ), m_Dsc01, DialogModes.NO );   

   return activeDocument.activeLayer;   

}   

function addToSelection(layerName) {   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putName( cTID( "Lyr " ), layerName );   

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 );   

   m_Dsc01.putEnumerated( sTID( "selectionModifier" ), sTID( "selectionModifierType" ), sTID( "addToSelection" ) );   

   m_Dsc01.putBoolean( cTID( "MkVs" ), false );   

   try {   

      executeAction( cTID( "slct" ), m_Dsc01, DialogModes.NO );   

   } catch(e) {}   

}   

function TemporaryAlpha() {   

   activeDocument.selection.store((this.alpha = activeDocument.channels.add()));   

   activeDocument.selection.deselect();   

   this.consume = function() {   

      activeDocument.selection.load(this.alpha);   

      this.alpha.remove();   

   }   

}   

layerColour("yellow");    

function layerColour(colour) {   

    switch (colour.toLocaleLowerCase()){   

        case 'red': colour = 'Rd  '; break;   

        case 'orange' : colour = 'Orng'; break;   

        case 'yellow' : colour = 'Ylw '; break;   

        case 'yellow' : colour = 'Ylw '; break;   

        case 'green' : colour = 'Grn '; break;   

        case 'blue' : colour = 'Bl  '; break;   

        case 'violet' : colour = 'Vlt '; break;   

        case 'gray' : colour = 'Gry '; break;   

        case 'none' : colour = 'None'; break;   

        default : colour = 'None'; break;   

        }   

    var desc = new ActionDescriptor();   

        var ref = new ActionReference();   

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

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

        var desc2 = new ActionDescriptor();   

        desc2.putEnumerated( charIDToTypeID('Clr '), charIDToTypeID('Clr '), charIDToTypeID(colour) );   

    desc.putObject( charIDToTypeID('T   '), charIDToTypeID('Lyr '), desc2 );   

    executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );   

};  

if(box.group8.value){   

if( app.documents.length > 0 ){ 

    duplicateToAll(); 

function duplicateToAll(){ 

    docs = app.documents; 

    curDoc = app.activeDocument; 

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

        if(curDoc != docs){ 

        var curLayer; 

        try { curLayer = docs.activeLayer; } catch(e) {} 

        curDoc.activeLayer.duplicate(docs,ElementPlacement.PLACEATBEGINNING); 

        } 

        app.activeDocument = curDoc; 

    } 

function cTID(s){return charIDToTypeID(s)} 

function sTID(s){return stringIDToTypeID(s)} 

box.close(); 

JJMack
Community Expert
JJMackCommunity ExpertCorrect answer
Community Expert
April 1, 2019

Yes I did it the same way using their math way using the document width and height.

I wish Adobe would fix reported acknowledged bugs

It is not just resize selection I may be any transform like transforming a layer size If the is an active selection  and history is suspended  Adobe Scripting back up the document up a history state. Reported years ago. Photoshop: Script bug resize layer back document up one history state | Photoshop Family Customer Community

I seen script posted here the were bitten more than once they were backed up several history states.

// If you delete last line script works properly, but record the history, with last line i got errors 

var startRulerUnits = app.preferences.rulerUnits;   

app.preferences.rulerUnits = Units.CM; 

var backup = app.activeDocument.historyStates.length; 

var box = new Window('dialog', "INFO"); 

var a = ["Employee1", "Employee2", "Employee3"];   

for (var i = 0; i < a.length; i += 1) {   

a["_"+a] = i;   

var c = ["001", "002", "003", "004","005", "006", "007","008", "009", "010"];   

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

c["_"+c] = i;   

box.group = box.add('group', undefined );   

box.group.orientation='row';  

box.group.alignment = 'right';  

box.group.text1 = box.group.add('statictext', undefined, "Employee"); 

box.group = box.group.add("dropdownlist", [25,40,160,60], a); 

box.group1 = box.add('group', undefined );  

box.group1.orientation='row';  

box.group1.alignment = 'right';  

box.group1.text1 = box.group1.add('statictext', undefined, "Iteration"); 

box.group1 = box.group1.add("dropdownlist", [25,40,160,60], c); 

box.group5 = box.add('group', undefined );  

box.group5.orientation='row';   

box.group5.alignment = 'right'; 

box.group5.text1 = box.group5.add('statictext', undefined, "Comments"); 

box.group5 = box.group5.add('edittext', [25,40,160,160],"",{multiline:true, scrollable:false}); 

box.group8 = box.add('group', undefined );  

box.group8.orientation='row';   

box.group8.alignment = 'right'; 

box.group8.text1 = box.group8.add('statictext', undefined, "Duplicate info"); 

box.group8 = box.group8.add("checkbox", undefined, "Yes"); 

var btnGroup = box.add ("group"); 

btnGroup.orientation = "row"; 

var btnOk = btnGroup.add("button", undefined, "OK");   

var btnCancel = btnGroup.add("button", undefined, "Cancel");  

box.center(); 

btnOk.onClick = function() {   

    box.close(1); 

};   

btnCancel.onClick = function() {   

    box.close(0); 

};  

if (box.show() === 1) {  

app.activeDocument.suspendHistory('INFO','main()');  

    } 

function main(){  

 

  var GroupPsdInfo = app.activeDocument.layerSets.add(); 

if(box.group1.selection){  

var it = box.group1.selection.text; 

GroupPsdInfo.name = "INFO _" + it;} 

else { 

    GroupPsdInfo.name = "PSD INFO";}  

var infobg = app.activeDocument.artLayers.add();   

var white = new SolidColor();    

white.rgb["hexValue"] = "ffffff"    

backgroundColor = white;   

var xwidth = app.activeDocument.width.value/app.activeDocument.resolution*5.5;

var yheight = app.activeDocument.height.value/app.activeDocument.resolution*5.5;

var selectedRegion = Array(Array(0,0), Array(xwidth,0), Array(xwidth,yheight), Array(0,yheight));

app.activeDocument.selection.select(selectedRegion);

app.activeDocument.selection.fill(app.backgroundColor) 

/* 

app.activeDocument.selection.selectAll();   

resizeSelection(5.5,5.5);  

function resizeSelection(horizontal, vertical){   

var strtRulerUnits = app.preferences.rulerUnits;   

var strtTypeUnits = app.preferences.typeUnits;   

app.preferences.rulerUnits = Units.CM;   

app.preferences.typeUnits = TypeUnits.PIXELS;   

var SB = activeDocument.selection.bounds;   

var Height = SB[3].value - SB[1].value;   

var Width = SB[2].value - SB[0].value;   

var onePixH = 100/Height;   

var onePixW = 100/Width;   

var newWidth = onePixW * horizontal;   

var newHeight = onePixH * vertical;   

activeDocument.selection.resize( newWidth , newHeight, AnchorPosition.TOPLEFT);   

app.preferences.rulerUnits = strtRulerUnits;   

app.preferences.typeUnits = strtTypeUnits; 

*/

infobg.name = "BG"; 

var col = new SolidColor(); 

col.cmyk.cyan = 0; 

col.cmyk.magenta = 0; 

col.cmyk.yellow = 0; 

col.cmyk.black = 0; 

var str = new SolidColor(); 

str.cmyk.cyan = 100; 

str.cmyk.magenta = 30; 

str.cmyk.yellow = 0; 

str.cmyk.black = 0; 

app.activeDocument.selection.fill(col); 

app.activeDocument.selection.stroke (str,12,StrokeLocation.INSIDE, ColorBlendMode.NORMAL, 100, false);   

activeDocument.selection.deselect();  

infobg.move(GroupPsdInfo,ElementPlacement.INSIDE)  

/* 

*/

if(box.group5.text){ 

var comm = box.group5.text; 

var comments = app.activeDocument.artLayers.add();   

comments.kind = LayerKind.TEXT; 

comments.textItem.contents = "Comments: \r" + box.group5.text.replace(/\n/g, "\r");  

comments.textItem.font = "Helvetica";   

comments.textItem.justification = Justification.LEFT;   

comments.textItem.position = [0.5, 1.2];   

comments.textItem.size = 10; 

comments.move(GroupPsdInfo,ElementPlacement.INSIDE)   

}  

else { 

var comments = app.activeDocument.artLayers.add();   

comments.kind = LayerKind.TEXT; 

comments.textItem.contents = "Comments: /";  

comments.textItem.font = "Helvetica";   

comments.textItem.justification = Justification.LEFT;   

comments.textItem.position = [0.5, 1.2];   

comments.textItem.size = 10; 

comments.move(GroupPsdInfo,ElementPlacement.INSIDE) 

if(box.group.selection){   

var ir = box.group.selection.text; 

var imageRetoucher = app.activeDocument.artLayers.add();   

imageRetoucher.kind = LayerKind.TEXT;   

imageRetoucher.textItem.contents = "Employee: " + ir;   

imageRetoucher.textItem.font = "Helvetica";   

imageRetoucher.textItem.justification = Justification.LEFT;    

imageRetoucher.textItem.position = [0.5, 0.7];    

imageRetoucher.textItem.size = 10; 

imageRetoucher.move(GroupPsdInfo,ElementPlacement.INSIDE)  

else {  

var imageRetoucher = app.activeDocument.artLayers.add();   

imageRetoucher.kind = LayerKind.TEXT;   

imageRetoucher.textItem.contents = "Employee: /";   

imageRetoucher.textItem.font = "Helvetica";   

imageRetoucher.textItem.justification = Justification.LEFT;    

imageRetoucher.textItem.position = [0.5, 0.7];    

imageRetoucher.textItem.size = 10; 

imageRetoucher.move(GroupPsdInfo,ElementPlacement.INSIDE)  

}  

var doc = app.activeDocument; 

var layerParent = doc.activeLayer.parent; 

if ( layerParent !== doc ) doc.activeLayer = layerParent; 

if (activeDocument.activeLayer.typename === 'LayerSet') {app.activeDocument.suspendHistory('closeGroup','closeGroup(activeDocument.activeLayer)');}   

function cTID(s){return charIDToTypeID(s)}   

function sTID(s){return stringIDToTypeID(s)}   

function openAllLayerSets( parent ){   

    for(var setIndex=0;setIndex<parent.layerSets.length;setIndex++){   

        app.activeDocument.activeLayer = parent.layerSets[setIndex].layers[0];   

        openAllLayerSets( parent.layerSets[setIndex]);   

    }   

};    

function closeAllLayerSets(ref) {   

          var layers = ref.layers;   

          var len = layers.length;   

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

                    var layer = layers;   

                    if (layer.typename == 'LayerSet') {closeGroup(layer); var layer = layers; closeAllLayerSets(layer);};   

          }   

}   

function openGroup(layerSet) {   

   var m_activeLayer = activeDocument.activeLayer; 

   var m_Layer_Dummy01 = layerSet.artLayers.add();   

   var m_Layer_Dummy02 = layerSet.artLayers.add();   

   layerSet.layers[1].name = layerSet.layers[1].name;   

   m_Layer_Dummy01.remove();   

   m_Layer_Dummy02.remove();   

   

   activeDocument.activeLayer = m_activeLayer;   

}   

function closeGroup(layerSet) {   

   var m_Name = layerSet.name;   

   var m_Opacity = layerSet.opacity;   

   var m_BlendMode = layerSet.blendMode;   

   var m_LinkedLayers = layerSet.linkedLayers;   

   

   var m_bHasMask = hasLayerMask();   

   if(m_bHasMask) loadSelectionOfMask();    

   if(layerSet.layers.length <= 1) {   

      addLayer();   

      var m_Tmp = activeDocument.activeLayer;   

      m_Tmp.name = "dummy - feel free to remove me";   

      activeDocument.activeLayer = layerSet;   

      ungroup();   

      addToSelection("dummy - feel free to remove me");   

      groupSelected(m_Name);   

   

   } else {   

      activeDocument.activeLayer = layerSet;   

      ungroup();   

      groupSelected(m_Name);   

   }   

   

   

   var m_Closed = activeDocument.activeLayer;   

   m_Closed.opacity = m_Opacity;   

   m_Closed.blendMode = m_BlendMode;   

   

   for(x in m_LinkedLayers) {   

      if(m_LinkedLayers.typename == "LayerSet")   

         activeDocument.activeLayer.link(m_LinkedLayers);   

   }   

   

   if(m_bHasMask) maskFromSelection();   

   

   return m_Closed;   

}    

function ungroup() {   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putEnumerated( cTID( "Lyr " ), cTID( "Ordn" ), cTID( "Trgt" ) );   

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 );   

   

   try {   

      executeAction( sTID( "ungroupLayersEvent" ), m_Dsc01, DialogModes.NO );   

   } catch(e) {}   

}   

function addLayer() {   

   var m_ActiveLayer          =    activeDocument.activeLayer;   

   var m_NewLayer             =    activeDocument.artLayers.add();   

   m_NewLayer.move(m_ActiveLayer, ElementPlacement.PLACEBEFORE);   

   

   return m_NewLayer;   

}    

function hasLayerMask() {   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putEnumerated( sTID( "layer" ), cTID( "Ordn" ), cTID( "Trgt" ));   

   var m_Dsc01= executeActionGet( m_Ref01 );   

   return m_Dsc01.hasKey(cTID('Usrs'));   

}   

function activateLayerMask() {   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putEnumerated( cTID( "Chnl" ), cTID( "Chnl" ), cTID( "Msk " ) );   

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 );   

   

   try {   

      executeAction( cTID( "slct" ), m_Dsc01, DialogModes.NO );   

   } catch(e) {   

      var m_TmpAlpha = new TemporaryAlpha();   

   

      maskFromSelection();   

      activateLayerMask();   

   

      m_TmpAlpha.consume();   

   }   

}   

function deleteMask(makeSelection) {   

   if(makeSelection) {   

      loadSelectionOfMask();   

   }   

   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putEnumerated( cTID( "Chnl" ), cTID( "Ordn" ), cTID( "Trgt" ) );   

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 );   

   

   try {   

      executeAction( cTID( "Dlt " ), m_Dsc01, DialogModes.NO );   

   } catch(e) {}   

}    

function selectLayerMask() {   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   

   

   m_Ref01.putEnumerated(cTID("Chnl"), cTID("Chnl"), cTID("Msk "));   

   m_Dsc01.putReference(cTID("null"), m_Ref01);   

   m_Dsc01.putBoolean(cTID("MkVs"), false );   

   

   

   try {   

      executeAction(cTID("slct"), m_Dsc01, DialogModes.NO );   

   } catch(e) {}   

}   

function loadSelectionOfMask() {   

   selectLayerMask();   

   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putProperty( cTID( "Chnl" ), cTID( "fsel" ) );   

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 );   

   var m_Ref02 = new ActionReference();   

   m_Ref02.putEnumerated( cTID( "Chnl" ), cTID( "Ordn" ), cTID( "Trgt" ) );   

   m_Dsc01.putReference( cTID( "T   " ), m_Ref02 );   

   

   try {   

      executeAction( cTID( "setd" ), m_Dsc01, DialogModes.NO );   

   } catch(e) {}   

}    

function maskFromSelection() {   

   if(!hasLayerMask()) {   

      var m_Dsc01 = new ActionDescriptor();   

      m_Dsc01.putClass( cTID( "Nw  " ), cTID( "Chnl" ) );   

      var m_Ref01 = new ActionReference();   

      m_Ref01.putEnumerated( cTID( "Chnl" ), cTID( "Chnl" ), cTID( "Msk " ) );   

      m_Dsc01.putReference( cTID( "At  " ), m_Ref01 );   

      m_Dsc01.putEnumerated( cTID( "Usng" ), cTID( "UsrM" ), cTID( "RvlS" ) );   

   

      try {   

         executeAction( cTID( "Mk  " ), m_Dsc01, DialogModes.NO );   

      } catch(e) {   

         activeDocument.selection.selectAll();   

         maskFromSelection();   

      }   

   } else {   

      if(confirm("Delete existing mask?", true, "Warning")) {   

         activateLayerMask();   

         deleteMask();   

      }   

   }   

function groupSelected(name) {   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putClass( sTID( "layerSection" ) );   

   m_Dsc01.putReference(  cTID( "null" ), m_Ref01 );   

   var m_Ref02 = new ActionReference();   

   m_Ref02.putEnumerated( cTID( "Lyr " ), cTID( "Ordn" ), cTID( "Trgt" ) );   

   m_Dsc01.putReference( cTID( "From" ), m_Ref02 );   

   var m_Dsc02 = new ActionDescriptor();   

   m_Dsc02.putString( cTID( "Nm  " ), name);   

   m_Dsc01.putObject( cTID( "Usng" ), sTID( "layerSection" ), m_Dsc02 );   

   executeAction( cTID( "Mk  " ), m_Dsc01, DialogModes.NO );   

   

   return activeDocument.activeLayer;   

}   

function addToSelection(layerName) {   

   var m_Dsc01 = new ActionDescriptor();   

   var m_Ref01 = new ActionReference();   

   m_Ref01.putName( cTID( "Lyr " ), layerName );   

   m_Dsc01.putReference( cTID( "null" ), m_Ref01 );   

   m_Dsc01.putEnumerated( sTID( "selectionModifier" ), sTID( "selectionModifierType" ), sTID( "addToSelection" ) );   

   m_Dsc01.putBoolean( cTID( "MkVs" ), false );   

   

   try {   

      executeAction( cTID( "slct" ), m_Dsc01, DialogModes.NO );   

   } catch(e) {}   

}   

function TemporaryAlpha() {   

   activeDocument.selection.store((this.alpha = activeDocument.channels.add()));   

   activeDocument.selection.deselect();   

   

   this.consume = function() {   

      activeDocument.selection.load(this.alpha);   

      this.alpha.remove();   

   }   

}   

layerColour("yellow");    

function layerColour(colour) {   

    switch (colour.toLocaleLowerCase()){   

        case 'red': colour = 'Rd  '; break;   

        case 'orange' : colour = 'Orng'; break;   

        case 'yellow' : colour = 'Ylw '; break;   

        case 'yellow' : colour = 'Ylw '; break;   

        case 'green' : colour = 'Grn '; break;   

        case 'blue' : colour = 'Bl  '; break;   

        case 'violet' : colour = 'Vlt '; break;   

        case 'gray' : colour = 'Gry '; break;   

        case 'none' : colour = 'None'; break;   

        default : colour = 'None'; break;   

        }   

    var desc = new ActionDescriptor();   

        var ref = new ActionReference();   

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

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

        var desc2 = new ActionDescriptor();   

        desc2.putEnumerated( charIDToTypeID('Clr '), charIDToTypeID('Clr '), charIDToTypeID(colour) );   

    desc.putObject( charIDToTypeID('T   '), charIDToTypeID('Lyr '), desc2 );   

    executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );   

};  

if(box.group8.value){   

if( app.documents.length > 0 ){ 

    duplicateToAll(); 

function duplicateToAll(){ 

    docs = app.documents; 

    curDoc = app.activeDocument; 

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

        if(curDoc != docs){ 

        var curLayer; 

        try { curLayer = docs.activeLayer; } catch(e) {} 

        curDoc.activeLayer.duplicate(docs,ElementPlacement.PLACEATBEGINNING); 

        } 

        app.activeDocument = curDoc; 

    } 

function cTID(s){return charIDToTypeID(s)} 

function sTID(s){return stringIDToTypeID(s)} 

box.close(); 

JJMack
milevicAuthor
Inspiring
April 1, 2019

First error is

after that

Legend
April 1, 2019

In order to understand, pleace show what the code is in lines 130-148

milevicAuthor
Inspiring
April 1, 2019

I group my code into a main function and I add at the end line

  1. app.activeDocument.suspendHistory('My changes','main()'); 

if I run script with this line, the script is partly done with some errors and history of scripts is still there, and if I run without this line, the script is normally done. What can be a problem?

Legend
April 1, 2019

What are these "some errors"?

milevicAuthor
Inspiring
March 28, 2019

i don't save history log, i just want to hide or delete, from history palette, steps which are coming with script realization so that does not disturb users.

JJMack
Community Expert
Community Expert
March 28, 2019

If you want to stop updating palettes like history layers etc you can toggle palettes in a script.  I often toggle palettes to speed up scripts execution. For Photoshop does not need to update palettes that are not visible.

Suspend history is very useful for speeding up  execution and also allows  the user to blackout the script  with  a single Ctrl+z.

I have also been bitten by a Scripting bug using suspend history.  I reported it but Adobe chose not to fix the bug.   If you use suspend history be careful if your script set selections  and does transforming you may be bitten.  It can be a very nasty bite.

JJMack
Tom Ruark
Inspiring
March 28, 2019

Can you use suspendHistory? That will give you just one entry for all your work. It is per document.

activeDocument.suspendHistory("Aaron Grimes Effect", "applyVideoExosure()");

JJMack
Community Expert
Community Expert
March 28, 2019

Tom does suspend history also stop recording the Document history log and metadata history recording.  I though there were a different flavor of history that did not actually record history state for they can not be use to back out changes.  The log just recordeed  what the did.

JJMack
JJMack
Community Expert
Community Expert
March 28, 2019

The document History log or the History Palette.  If log are you saving the log into metadata or a text  file or both ways.  If a Text file the file may be open and locked while the document is open in Photoshop.  You may not be able to Edit it, delete it or  clear it if  its in use by Photoshop. Are you trying to hide your image tampering? If you do not set your preference to history log your activity should not be logged when you edit their image.

JJMack