4 Replies Latest reply on Aug 2, 2016 10:55 AM by Joachim Hiller

    history state

    Joachim Hiller Level 1

      Hello everybody,

      I want to run a script but it should not be listed at any step in the history state. would be best if it were just a step visible, so for example, there is a frequency separation are performed. In the history state then should "frequency separation" are.

      Can someone help me because someone accidentally

        • 1. Re: history state
          JJMack Most Valuable Participant

          In Photoshop Scripting you can suspend recording of history states.


          However, there is a nasty bug in Photoshop that can do strange thing if you set a selection and it is active and you resize a layer Photoshop will back up one history state after the resize.  If you have suspended recording history states you will be backed up one state before the script was started.     For example If you paste in a new image layer than run the script to process that new image layer. If the script suspends recording history states then hits the bug the layer that was pasted in will be deleted.  What was current resized layer will not longer be around after it is resized it will be deleted when Photoshop back up one history state. Who can tell what the script will do next.   Photoshop most likely did something before the resize that it thought would be recorded in history but was not because history recording was suspended by the script. So when Photoshop tried to delete the history state it deleted a state recorder before the script was started,


          This bug is in every Photoshop version I have tested.   Adobe acknowledge my bug report is a bug but has not bothered to fix it.

          • 2. Re: history state
            Joachim Hiller Level 1

            Many thanks for the answer. I'm still trying to understand, sorry my English is not good. Did you give me maybe an example as I suspend the recording of history states.

            That would be great. Thank you for the effort.

            best regards

            • 3. Re: history state
              JJMack Most Valuable Participant



              /* ==========================================================
              // 2013  John J. McAssey (JJMack) 
              // ======================================================= */
              // This script is supplied as is. It is provided as freeware. 
              // The author accepts no liability for any problems arising from its use.
              // I set a shortcut key in my case F5 to this Photoshop script mainly for doing Window screen capturing of:
              // desktop displays, Active window and selected area copy to clipboard. The script log the cardboard into a document with the name clipboard. 
              <about>$$$/JavaScripts/PasteClipboard/About=JJMack's Paste Clipboard into Clipboard document.^r^rCopyright 2014 Mouseprints.^r^rJJMack's Script.^r
              NOTE:New Clipboard Document will be open if necessary</about>
              <category>JJMack's Script</category>
              // enable double-clicking from Mac Finder or Windows Explorer
              #target photoshop // this command only works in Photoshop CS2 and higher
              // bring application forward for double-click events
              if (!documents.length) {
                NewCliboardDoc (); 
                app.activeDocument.suspendHistory('pasteClipboard','main(true)'); // New document opened proceed
              else { //locate Document clipboard
                for (var i=0;i<app.documents.length;i++) { 
                if (app.activeDocument.name == "Clipboard"){break;}
                if (app.activeDocument.name != "Clipboard"){
                NewCliboardDoc ();
                app.activeDocument.suspendHistory('pasteClipboard','main(true)'); // New document opened proceed
                else {app.activeDocument.suspendHistory('pasteClipboard','main(false)'); } // Old Clipboard Document found
              //                            main function                                  //
              function main(newFile) {
                // declare local variables
                var orig_ruler_units = app.preferences.rulerUnits;
                app.preferences.rulerUnits = Units.PIXELS; // Set the ruler units to PIXELS
                try { 
                activeDocument.paste();    // past in clipboard may fail enclose in try
                var LB = app.activeDocument.activeLayer.bounds; // Get the bounds of the work layer
                var LWidth = (LB[2].value) - (LB[0].value); // Area width
                var LHeight = (LB[3].value) - (LB[1].value); // Area height
                if(newFile) {
                app.activeDocument.resizeCanvas(LWidth, LHeight, AnchorPosition.TOPLEFT);
                app.activeDocument.selection.selectAll(); // select all
                // Left('AdLf'); Right('AdRg'); Top('AdTp'); Bottom('AdBt'); Center Horizontal('AdCH'); Center Vertical('AdCV');
                align("AdCH");align("AdBt"); //Align to selection center bottom
                catch(e) { 
                if(newFile) app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                alert("Clipboard Empty"); 
                app.preferences.rulerUnits = orig_ruler_units; // Reset units to original settings
              //                           main function end                               //
              function NewCliboardDoc () {
                // app.documents.add([width][, height][, resolution][, name][, mode][, initialFill][, pixelAspectRatio][, bitsPerChannel][, colorProfileName])
                var Clipboard = app.documents.add( null, null, 100, "Clipboard", NewDocumentMode.RGB, null, null, null, "sRGB IEC61966-2.1");
              function align(method) {
                var desc = new ActionDescriptor();
                var ref = new ActionReference();
                ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
                desc.putReference( charIDToTypeID( "null" ), ref );
                desc.putEnumerated( charIDToTypeID( "Usng" ), charIDToTypeID( "ADSt" ), charIDToTypeID( method ) );
                executeAction( charIDToTypeID( "Algn" ), desc, DialogModes.NO );
              function SetViewFitonScreen() {
                  var desc1 = new ActionDescriptor();
                  var ref1 = new ActionReference();
                  ref1.putEnumerated(charIDToTypeID('Mn  '), charIDToTypeID('MnIt'), charIDToTypeID('FtOn'));
                  desc1.putReference(charIDToTypeID('null'), ref1);
                  executeAction(charIDToTypeID('slct'), desc1, DialogModes.NO);
              • 4. Re: history state
                Joachim Hiller Level 1

                Many thanks for your help.