Skip to main content
Mattmcquiff
Inspiring
April 14, 2013
Answered

Create a snapshot and return to snapshot, using Applescript?

  • April 14, 2013
  • 1 reply
  • 1950 views

I'm just trying to create an applescript that will allow me to create a snapshot in my history and then later in the script select that history state/snapshot?

This topic has been closed for replies.
Correct answer Muppet Mark

You should be able to do this using the DOM in AppleScript or JavaScript…

tell application "Adobe Photoshop CS5"

          tell the current document

                    set hS to current history state

  change mode to Lab -- do whatever your stuff is…

                    set current history state to hS

          end tell

end tell

var doc = app.activeDocument;

var hS = doc.activeHistoryState;

doc.changeMode( ChangeMode.LAB );

app.refresh();

doc.activeHistoryState = hS;



1 reply

Paul Riggott
Inspiring
April 14, 2013

I think you will need to call a javaScript to do this...

function createNamedSnapshot(name) {
    var desc = new ActionDescriptor();
        var ref = new ActionReference();
        ref.putClass( charIDToTypeID('SnpS') );
    desc.putReference( charIDToTypeID('null'), ref );
        var ref1 = new ActionReference();
        ref1.putProperty( charIDToTypeID('HstS'), charIDToTypeID('CrnH') );
    desc.putReference( cTID('From'), ref1 );
    desc.putString( charIDToTypeID('Nm  '), name );
    desc.putEnumerated( charIDToTypeID('Usng'), charIDToTypeID('HstS'), charIDToTypeID('FllD') );
    executeAction( charIDToTypeID('Mk  '), desc, DialogModes.NO );
};

function revertNamedSnapshot(name) {
    var desc = new ActionDescriptor();
        var ref = new ActionReference();
        ref.putName( charIDToTypeID('SnpS'), name );
    desc.putReference( charIDToTypeID('null'), ref );
    executeAction( charIDToTypeID('slct'), desc, DialogModes.NO );
};

Muppet MarkCorrect answer
Inspiring
April 14, 2013

You should be able to do this using the DOM in AppleScript or JavaScript…

tell application "Adobe Photoshop CS5"

          tell the current document

                    set hS to current history state

  change mode to Lab -- do whatever your stuff is…

                    set current history state to hS

          end tell

end tell

var doc = app.activeDocument;

var hS = doc.activeHistoryState;

doc.changeMode( ChangeMode.LAB );

app.refresh();

doc.activeHistoryState = hS;



Inspiring
April 14, 2013

I think snapshots are better as you don't have to worry about the number of steps the script creates between setting and restoring. There is a chance that the number of steps in the script pushes the stored historyState off the panel and you can't restore later.