0
Engaged
,
/t5/photoshop-ecosystem-discussions/how-to-select-the-last-history-state/td-p/10366968
Feb 23, 2019
Feb 23, 2019
Copy link to clipboard
Copied
Hello!
This script selects the first history state.
var doc = app.activeDocument;
doc.activeHistoryState = doc.historyStates [0];
independently of the quandity of historical states, how do I select only the last one?
Thank you.
TOPICS
Actions and scripting
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer
Guide
,
Feb 23, 2019
Feb 23, 2019
var doc = app.activeDocument; | |
doc.activeHistoryState = doc.historyStates[doc.historyStates.length-1]; |
Explore related tutorials & articles
4
Replies
4
Guide
,
/t5/photoshop-ecosystem-discussions/how-to-select-the-last-history-state/m-p/10366969#M232914
Feb 23, 2019
Feb 23, 2019
Copy link to clipboard
Copied
var doc = app.activeDocument; | |
doc.activeHistoryState = doc.historyStates[doc.historyStates.length-1]; |
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
mauricior6328708
AUTHOR
Engaged
,
/t5/photoshop-ecosystem-discussions/how-to-select-the-last-history-state/m-p/10366970#M232915
Feb 24, 2019
Feb 24, 2019
Copy link to clipboard
Copied
Perfect! Thank you SuperMerlin
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
/t5/photoshop-ecosystem-discussions/how-to-select-the-last-history-state/m-p/13953849#M745347
Jul 21, 2023
Jul 21, 2023
Copy link to clipboard
Copied
Any way to add logic to find out what the active history state is? I want to make a conditional toggle, to go from 0 to Max. But it doesn't look like activeHistoryState shows that info.
app.activeDocument.activeHistoryState
------------------------
1) name=Deselect
2) parent=[Document example.psd]
3) snapshot=false
4) typename=HistoryState
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
LATEST
/t5/photoshop-ecosystem-discussions/how-to-select-the-last-history-state/m-p/13953883#M745349
Jul 21, 2023
Jul 21, 2023
Copy link to clipboard
Copied
This seems to function the way I want, it's just a little more binary since I can't lookup the number, but I guess that's not necessarily a bad thing.
//History State 0 is open document
aD = app.activeDocument;
aH = aD.activeHistoryState;
aHL = aD.historyStates.length;
if(aH != aD.historyStates[aHL-1]) aD.activeHistoryState = aD.historyStates[aHL-1];
else{aD.activeHistoryState = aD.historyStates[0]}
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more