Create snapshots of history - code does not

I got this code of the forums here - just do a minor cleanup (using the stringIDToTypeID instead of charIDToTypID which is not also readable).

But does not run this code. It works well until the point where I call executeAction() - what is the problem? JSX code below!

Create

function sTID(s) { return stringIDToTypeID(s); };

function createSnapshot(name){
// Creates a history snapshot. Not possible via DOM - have to use Action Manager
    alert("inside createSnapshot");


    var desc = new ActionDescriptor();
    var ref1 = new ActionReference();
    var ref2 = new ActionReference();


    ref1.putClass( sTID("Snapshot") );
    desc.putReference( sTID("Null"), ref1 );
    ref2.putProperty( sTID("HistoryState"), sTID("CurrentHistoryState") );
    desc.putReference( sTID("From"), ref2 );
    desc.putString( sTID("Name"), name );
    desc.putEnumerated( sTID("Using"), sTID("HistoryStateSource"), sTID("FullDocument") );


    executeAction( sTID("Make"), desc, DialogModes.NO ); // Script halts here
}

HistoryState and HistoryStateSource has a contradictory CharID "HST" so, naturally, I tested all possible configurations 4 - neither work!

Other functions (untested):

Set

function setSnapshot(name){
// Sets the history to a previous snapshot. Not possible via DOM - have to use Action Manager
    alert("inside setSnapshot");


    var desc = new ActionDescriptor();
    var ref = new ActionReference();


    ref.putName( sTID("Snapshot"), name );
    desc.putReference( sTID("Null"), ref );


    executeAction( sTID("Select"), desc, DialogModes.NO );
    alert("reverted snapshot");
}

Delete

function removeSnapshot(name){
// Removes a history snapshot. Not possible via DOM - have to use Action Manager
    alert("inside removeSnapshot");


    var desc = new ActionDescriptor();
    var ref = new ActionReference();


    ref.putName( sTID("Snapshot"), name );
    desc.putReference( sTID("Null"), ref );


    executeAction( sTID("Delete"), desc, DialogModes.NO );
    alert("removed snapshot");
}

You have all the names wrong.

function createSnapshot(name){
function sTID(s) { return stringIDToTypeID(s); };
    var desc = new ActionDescriptor();
    var ref1 = new ActionReference();
    var ref2 = new ActionReference();
    ref1.putClass( sTID("snapshotClass") );
    desc.putReference( sTID("null"), ref1 );
    ref2.putProperty( sTID("historyState"), sTID("currentHistoryState") );
    desc.putReference( sTID("from"), ref2 );
    desc.putString( sTID("name"), name );
    desc.putEnumerated( sTID("using"), sTID("historyState"), sTID("fullDocument") );
    executeAction( sTID("make"), desc, DialogModes.NO );
};

Allways check what's the stringId from a charId using: -.

$.writeln(typeIDToStringID(charIDToTypeID('From'))); 

Tags: Photoshop

Similar Questions

  • Reinstall Windows 7 and now the activation code does not work

    I upgraded my PC with an AM2 chip to an i5.  I had to reinstall windows and now my activation code does not work.   It's like 2-3 years, I forgot when I built the computer.  It installed on my other windows 7 install and created the windows.old folder.  How can I get reactivated?  I used the same code since I built my computer.

    Thank you

    Have you tried to restart by phone?

    How to activate Windows 7 manually (activate by phone)
     
    1) click Start and in the search for box type: slui.exe 4
     
    (2) press the ENTER"" key.
     
    (3) select your "country" in the list.
     
    (4) choose the option "activate phone".
     
    (5) stay on the phone (do not select/press all options) and wait for a person to help you with the activation.
     
    (6) explain your problem clearly to the support person.
     
    http://support.Microsoft.com/kb/950929/en-us

  • Create a subfolder of bookmark in time real bookmarking a page in a folder that I created for a registered earlier does not work

    Create a subfolder of bookmark in time real bookmarking a page in a folder of bookmarks, I created a saved bookmark previously does not work.

    Previously on a Windows XP computer, I could choose the "select" option and create a new folder under the folder I chose to put my new bookmark. "." On this computer, the 'new folder' option is not clickable.

    I thought about it. Thanks anyway.

  • The button create a new paragraph style does not work for me, is this a bug or something stupid I did?

    The button create a new paragraph style does not work for me, is this a bug or something stupid I did?

    Pages on El Capitan 10.11.1 v5.6.1.

    I just created a quote indented using ITC Garamond Book Italic with left and right margins altered. Well selected, I clicked on the + symbol in the paragraph, named the new Styles pop-up style Indented quote and you press return.

    Always selected in the body of the document, I applied the body paragraph Style to restore the normal formatting and then with the text again, the paragraph of citation Style indented - who worked as expected.

    If you want that your new Style of paragraph to survive across documents, you will need to save it in a model. You can also have two different Pages, documents open in Pages v5.6.1, and copy/paste the custom styles between the selected text in these documents by using the Format menu.

  • unlock code does not match system

    get the message "unlock code does not match system" whenever I try to open my game.can someone help me "

    Hello catou212,

    You need locate the manufacturer of the game in question and contact the Helpdesk of the manufacturer directly to get the correct unlock code.

    Hope this helps

    Chris.H
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Zip code does not match with the Service request number

    Hello
    I can, check the State of repair of my Xbox to the t.
    It keeps giving the same error (ZIP Code does not match with the Service request number).

    I tried to register the product.
    but it seems impossible, if it has a status of repair open.

    a catch 22.

    Hello

    I suggest you go through the following link.

    http://www.Xbox.com/en-us/

  • laptop HP 250 g2: off system code does not

    s

    HP 250 g2 portable system disabled the code does not

    Hello

    Have you changed anything on your machine? Please use the following code to the ICF disabled first code:

    44784339

    Kind regards.

  • I nee a new code, my code does not work

    Dear Sir or Madam,

    a friend restalled my laptop and I need a new code for my window at work, because my old code does not, please could you give me the phone number to get a new code or could you give me a new code.

    Thank you

    Yours sincerely

    bobsargent

    Hello

    You don't need to buy a new product key.

    Use the appropriate method of re-setup to reinstall Vista and activate it.

    There are several methods to reinstall Vista.

    There is no Windows Vista downloads available from Microsoft.

    You can contact your computer manufacturer and ask them to send you a set of recovery disks.

    They should do this for a small fee.

    To reinstall Vista using their recovery disk/s, you start from the 1st recovery disk they provide and follow the manufacturer's instructions to reinstall:

    You need to change the Boot order to make the DVD/CD drive 1st in the boot order:

    How to change the Boot order in BIOS:

    http://pcsupport.about.com/od/fixtheproblem/SS/bootorderchange.htm

    "How to replace Microsoft software or hardware, order service packs and replace product manuals.

    http://support.Microsoft.com/kb/326246

    And if you have never received a recovery disk when you bought your computer, there should be a recovery Partition on the hard drive to reinstall Vista on how you purchased your computer.

    The recovery process can be started by pressing a particular combination of the key or keys at startup. (Power on / start)

    Maybe it's F10, F11, Alt + F10, etc., depending on the manufacturer.

    Ask them to the proper key sequence.

    And if you do not score a manufacturer of recovery on your hard drive, you should be able to make your own recovery from her disks to reinstall the operating system.

    Go to programs > name of the manufacturer of your computer > then their system or recovery tools software topics for them, depending on how it is formulated.

    If you can't find any reference to it, contact the manufacturer for advice on how to make these recovery disks.

    Some manufacturers have more available Vista recovery disks.

    If this happens, you may need to try this instead:

    You can also borrow and use a Microsoft Vista DVD, which contains the files for the different editions of Vista (Home Basic, Home Premium, Business and Ultimate) must be installed. The product key on your computer / Laptop box determines what Edition is installed.

    Other manufacturers recovery DVDs are should not be used for this purpose.

    And you need to know the version of 'bit' for Vista, as 32-bit and 64-bit editions come on different DVDs

    Here's how to do a clean install of Vista using a DVD of Vista from Microsoft:

    "How to do a clean install and configure with a full Version of Vista '

    http://www.Vistax64.com/tutorials/117366-clean-install-full-version-Vista.html

    And once the operating system is installed, go to your computer manufacturer's website and get the latest drivers for your particular model or laptop computer.

    And phone Activation may be necessary when you use the above installation method.

    "How to activate Vista normally and by Activation of the phone '

    http://www.Vistax64.com/tutorials/84488-activate-Vista-phone.html

    See you soon.

  • A refurb Lenovo/IBM PC windows 7.0 SW, software code does not work for charging SW after a system restore

    A refurb Lenovo/IBM PC windows 7.0 SW, software code does not work for charging SW after a system restore. How can I get a new one

    Skip, enter the product key, and then complete the installation.

    Try the phone activation:

    How to activate Windows 7 manually (activate by phone)
     
    1) click Start and in the search for box type: slui.exe 4
     
    (2) press the ENTER"" key.
     
    (3) select your "country" in the list.
     
    (4) choose the option "activate phone".
     
    (5) stay on the phone (do not select/press all options) and wait for a person to help you with the activation.
     
    (6) explain your problem clearly to the support person.
     
    http://support.Microsoft.com/kb/950929/en-us

  • When I try to read Blu - Ray, it says "Windows Media Player cannot play the DVD. The disk has been created in a way that does not support the player. »

    Original title: Blu - Ray

    My computer can read blu - ray, but when I try to play one, it says "Windows Media Player cannot play the DVD. The disk has been created in a way that does not support the player. "How should I do?

    Hello
     
    The Blu - ray disc format is not supported in Windows Media Player. To play a Blu - ray Disc, you must use a non-Microsoft program that supports playback of Blu ray and a device that can play Blu ray discs.
     
    See the article mentioned below:
     
     
    Read a CD or a DVD in Windows Media Player: http://windows.microsoft.com/en-us/windows7/Play-a-CD-or-DVD-in-Windows-Media-Player
     
    Note: Using third-party software, including hardware drivers can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the use of third-party software can be solved. Software using third party is at your own risk.
  • "Windows Media Player cannot play the DVD. The disk has been created in a way that does not support the player. »

    Hi all

    I copied a video to holiday on a Virgin DVD + RW but when I try to play on the same laptop where it was copied from, I get the message "Windows Media Player cannot play the DVD. The disk has been created in a way that does not support the player. "Any ideas please? I can normally play DVD pre-recorded ok.

    Thanks in advance.

    Hi all

    I copied a video to holiday on a Virgin DVD + RW but when I try to play on the same laptop where it was copied from, I get the message "Windows Media Player cannot play the DVD. The disk has been created in a way that does not support the player. "Any ideas please? I can normally play DVD pre-recorded ok.

    Thanks in advance.

    =====================================
    DVD Maker might be worth a try:

    Windows 7 - burn a video DVD with Windows DVD Maker disc
    http://Windows.Microsoft.com/en-us/Windows7/burn-a-DVD-video-disc-with-Windows-DVD-Maker
    (Windows 7 Home Premium / Professional / Ultimate / Enterprise)

  • jQuery code does not work in phonegap

    Someone gave me a code https://jsfiddle.net/adeneo/2uod274d/ jsfiddle

    It works well in jsfiddle, but when I put the code in my Xcode and amended to incorporate my code and run it in the Simulator, the code does not work at all (i.e., no data is stored in the local storage)

    I am building an app for iOS with phonegap. JS:

    <script type="text/javascript" src="cordova.js"></script>
      
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
      
    <script type="text/javascript" src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script>

      
    <script type="text/javascript">
      document.addEventListener("deviceready",onDeviceReady,false);

      function onDeviceReady() {

      document.getElementById("btnSave").addEventListener("click",saveData,false);
      document.getElementById("btnShow").addEventListener("click",showData,false);
    }

      function saveData(){
      var data = window.localStorage.getItem("date");

      var dates = data ? JSON.parse(data) : [];

      dates.push( new Date() );

      window.localStorage.setItem("date", JSON.stringify(dates));

      alert("Your data is stored");
      }

      function showData() {
      var data = JSON.parse(window.localStorage.getItem("date"));
      console.log(data);
      $('#res').html(JSON.stringify(data));
      $(this).html('Update result');
      }

    < /script >

    HTML:

    <button id="btnSave"> Save Data </button>

      
    <button id="btnShow"> Show Data </button>

    I don't know what is happening because the code works well in jsfiddle, but for some reason any just does not work in my phonegap.

    My version of phonegap 5.3.6 cordova version 5.3.3

    Post edited by: Fang Kerry, I added my complete code is easier to see the problem (if any)

    jQuery has nothing to do with this, as far as I can tell (so not sure why it is in your title). The problem is that the result of JSON.parse (data) is not an array, what you think it is, it's a chain. The chain respond well to 'push '. I get that when you use this code in jsfiddle he is somehow coming out as a table, but I think it must be because of something done jsfiddle. When I do the same commands in the console of my browser, I get a string, not a table, so your problem.

    Instead:

    function deserializeDates() {
        var data = window.localStorage.getItem("date");
        var dates = []; // worst case, we'll return an empty array.
        if (data) {
            try {
                dates = JSON.parse(data);
                 // handle the case that dates is a single item and not an array
                if (!(dates instanceof Array)) {
                    dates = [dates];
                }
            } catch (err) {
                 // the stored dates failed to parse for some reason; you might want to do something about it
                 console.log("Failed to parse " + data);
             }
        }
        return dates;
    }
    
    function serializeDates(dates) {
        window.localStorage.setItem("date", JSON.stringify(dates));
    }
    
    function saveData(){
         var dates = deserializeDates();
        dates.push( new Date() );
         serializeDates(dates);
        alert("Your data is stored");
    }
    
    function showData() {
         var dates = deserializeDates();
        console.log(dates);
        ...
      }
    
  • I have Adobe Creative Suite 5 Master Collection. Activation code does not work?

    I have Adobe Creative Suite 5 Master Collection. Activation code does not work when I install it on my Macbook. It installed properly on my Windows PC, however.

    I thought the serial numbers for specific version CS5... Mac - GOLD - Windows, not both

    You sure have a serial number which is good for both?

  • Activation code does not have Lightroom?

    Bought Lightroom cd with the code, could not install, cd was broken. Downloaded Lightroom, but the code does not work here.  What should do?

    You have a serial number, or a redemption code?

    Redemption Code http://helpx.adobe.com/x-productkb/global/redemption-code-help.html

    - and https://forums.adobe.com/thread/1572504

  • Packer of creative cloud in creating a package that I can install do not.  He goes through the motions, download all updates, create setup file, but it does not work despite the fact that there are no errors in the log files

    Packer of creative cloud in creating a package that I can install do not.  He goes through the motions, download all updates, create setup file, but it does not work despite the fact that there are no errors in the log files

    After hitting my head against the desk to repeatedly create packages, try on different computers I have finally found a solution.

    These packages have been copied on an external drive, if I try and install from the external drive, which is a common practice, it fails.

    If I then copy this file pkg from the outside, to the computer I install, then run it, it will to and moved very well.

    That is mind-boggling stupid, because it's rare that you have to copy the file into any computer, it is less always installed off the coast of externally, and many people in the company are pushing on the network and the management of the suites so there is a serious problem in Adobe package manager if this is the case where it cannot manage the Middle installed offshore.

    I hope that if anyone else is having problems so it suits.

Maybe you are looking for

  • ITunes consolidation problem

    If Itunes the other day has decided to return to the folder default itunes media rather than one I chose to use and use successfully for several years. Of course all of the links broken and I couldn't play anything. I'm now trying to get back links b

  • HP eny m6-1205 x laptop: the upgrade to 8.1 to 8.0

    I am trying to improve from 8.0 to 8.1, but it says there no info you new software so it can not install. I'm not too sure if the operating system is Windows 8 (32-bit) or (64-bit)

  • increase the resolution of 200 Hz to 1000 Hz

    I need speed my kinematic data must match the kinetic data that I use for my analysis by a factor of 5. I tried a linear interpolation, but as the ntimes value grows flattens my signal and I end up losing the shape of the data. This happens for inter

  • I have all three service packs for xp on my laptop. everything can I? or just sp3?

    I downloaded SP3 for windows xp on my laptop, I also always SP2 and SP1. My question is: can I remove servicepacks 1 & 2 of my pc since I updated to SP3?   They take a lot of space on my laptop which is slow anyway.  Also how knowledge or know what p

  • How to reset my Vaio to factory without recovery media setting

    Hi all recently, I've been hurt by the non-stop Windows Installer pop-ups This has happened since my last update of Windows I have tried so many menthods online, not helped one of the pop-up tries to install Media Gallery now I am unable to Vaio Care