-
1. Re: Create a snapshot and return to snapshot, using Applescript?
Paul Riggott Apr 14, 2013 3:34 AM (in response to Mattmcquiff)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 ); }; -
2. Re: Create a snapshot and return to snapshot, using Applescript?
Muppet Mark Apr 14, 2013 6:06 AM (in response to Paul Riggott)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;
-
3. Re: Create a snapshot and return to snapshot, using Applescript?
Michael L Hale Apr 14, 2013 6:57 AM (in response to Muppet Mark)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.
-
4. Re: Create a snapshot and return to snapshot, using Applescript?
Muppet Mark Apr 14, 2013 9:14 AM (in response to Michael L Hale)I don't doubt you Mike… and Paul's action manager can be called by either… So no problems there… I was just making the point that document history is a standard scriptable feature of the app…
-
5. Re: Create a snapshot and return to snapshot, using Applescript?
Michael L Hale Apr 14, 2013 12:34 PM (in response to Muppet Mark)I was just making the point that document history is a standard scriptable feature of the app…
Yes, it is. And I wasn't trying to say one shouldn't use it. I use them when there are only one or two steps in the script between setting and restoring.
Between historyStates, snapshots, and suspendHistory() we don't have to worry as much as we once did about a script wiping out the user's history.

