• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to select the last history state

Engaged ,
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?

Capturar.JPG

Thank you.

TOPICS
Actions and scripting

Views

997

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Feb 23, 2019 Feb 23, 2019
var doc = app.activeDocument; 
doc.activeHistoryState = doc.historyStates[doc.historyStates.length-1];

Votes

Translate

Translate
Adobe
Guide ,
Feb 23, 2019 Feb 23, 2019

Copy link to clipboard

Copied

var doc = app.activeDocument; 
doc.activeHistoryState = doc.historyStates[doc.historyStates.length-1];

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 24, 2019 Feb 24, 2019

Copy link to clipboard

Copied

Perfect! Thank you SuperMerlin

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
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

  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 21, 2023 Jul 21, 2023

Copy link to clipboard

Copied

LATEST

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]}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines