Assign a Keyboard Shortcut to the last History State?

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

RSmith

Assign a Keyboard Shortcut to the last History State?

Post by RSmith »

I'm new to PS Scripting but have perused the PS6 scripting documentation. I want to assign a keyboard shortcut to the last HistoryState so I can repeat the last command - no matter what the last performed command may have been. Can that be done with PS scripting?

Scott Kelby requested this as his most wanted Photoshop feature. Here's his rationale:

If I could add just one feature to the next version of Photoshop, it would be a “Do That Last Step Again” keyboard shortcut.

Here’s why this would rock: How many times have you had to do something like resize three photos to a particular size, and since you’re only resizing three of them this one time, it doesn’t make sense to go write an Action for them because by the time you actually wrote the action, you could have already been done with the resizing manually. Short, repetitive stuff like that happens all the time during our work, and the only way to do them is just to sit there and down them — one at a time.

Worse yet, what if it’s two steps to four photos? Like resize to 610 pixels wide and apply an Unsharp Mask. Ugh!

So imagine if you could resize a photo, and then just press a keyboard shortcut to apply that exact same resize to the next photo? Or if you could add a Modifier key (like the Alt key) and now it applies your last two steps? (Resize and Unsharp Mask) Add another modifier (like Shift) and it applies your last THREE steps! (Resize, Unsharp Mask and Crop!). All three moves — just one shortcut. Sweet!

Imagine how that would boost your productivity day in and day out (but of course, like any Photoshop feature, some folks would never use it at all). Anyway, that’s the one simple feature I would love to see added to the next version of Photoshop (I’ve been wanting this one for years!)

Can the last three HistoryStates be read into an array and their respective index values used in conjunction with an event listener to capture the modifier(s) and replay a specific subset like Scott writes about? Thanks.

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

RSmith

Assign a Keyboard Shortcut to the last History State?

Post by RSmith »

Follow-up: I can see a challenge already. Specific HistoryStates are relevant to only the current document, correct? Application across documents is then impossible, correct?

Might a better approach be, if possible:

1. Ctrl-Shift-F12 = read last three history states.
2. Programatically create an Action with the three states as recorded steps.
3. Programatically playback Action.

Possible?
Mike Hale

Assign a Keyboard Shortcut to the last History State?

Post by Mike Hale »

HistoryStates will not be of any help for this. Not only are they document specific as you noted but, as the name implies, it is only the change in the state of that document. For example when you resize a document the historyState's name is 'Image Size'. That state does not have any info about how the image was resized only the state of the document after the resize.

But everything that you can do in an action creates an event. That event has details about what was done in an actionDescriptor. I guess you could have an 'ALL' event handler that stores the descriptor of the last three commands somewhere. Then have another script that reads those descriptors and 'plays' them back. It would be possible to have a modifier determine how many steps to play back. But the event handler would have to run all the time. That would effect Photoshop's performance. And storing/reading the descriptors may be tricky. I don't think actions performed by a script would fire the 'ALL' event handler but if it does you would also need a way not to store the descriptors when the second script is running. But I think it could work if someone was willing to spend the effort.

But I think that Photoshop already has a great method for playing the same steps repeatedly. I think it doesn't really make sense to keep an action that you only need for three images but as you will have to do the steps for the first image anyway why not record a 'disposable' action for the first image and play it back for as many other images as needed?

I think tying up resources for something that you might want to do on the old occasion is not a good idea.
RSmith

Assign a Keyboard Shortcut to the last History State?

Post by RSmith »

Mike,

Thanks for your thorough, and logical, response. Alt-F9 works for me and Custom Sets of Actions wouldn't take long to invoke for common sequential tasks in a workflow.

Cheers, mate.