Join 3,564 readers in helping fund MetaFilter (Hide)


Step Backwards in Photoshop, Using Javascript
June 2, 2010 1:49 PM   Subscribe

How do I access the previous history state in Javascript for Photoshop?

I'm working on a script in Photoshop using Javascript. To simplify the question, let's just say that I want to duplicate the function of the "Step Backward" menu item. Which is to say: I want to move one step back in the history list from the current history state. How would I do this?

I've found scripts that move back one step from the last history state, but I want this to step back even if I've clicked on the history list so that I'm somewhere in the middle, with "future" history steps in grey.

Frustratingly, Javascript for Photoshop seems to give you access to the activeHistoryState object, but that doesn't seem to have any reference to where the active history state is on the history list. Am I missing something?

Alternatively, if there's a way in Javascript to simply execute menu items by name, I'd accept that. Obviously, I could use an Action, rather than a script, to Step Backward, but I want to do things before and after the Step Backward that I can only do with Javascript.

Also, as I understand it, snapshots are useless to me, because I want the script to be able to revert to a state that exists before the script started running.

Anyone have something that can help me here? I'm using Photoshop CS5.
posted by lore to Computers & Internet (1 answer total)
 
Given that in the docs you can rollback the current changes with:
docRef.activeHistoryState = docRef.historyStates[0]
My guess is that you can get the full history (I'm guessing this is an array of objects) with just docRef.historyStates, so find out how much history there is with docRef.historyStates.length

I've not done any scripting for PhotoShop CS5, just going based on my experience with JS.
posted by artlung at 4:34 PM on June 2, 2010


« Older Have Americans evolved their s...   |  Is there anyway to replicate F... Newer »
This thread is closed to new comments.