No internet connection
  1. Home
  2. How to

True session auto backup...

By Yujiro Yonetsu @Yujiro_Yonetsu
    2022-05-28 12:55:46.412Z

    Hello!

    I work with Pro tools and have many times had trouble with auto session backup, a feature unique to Pro tools.

    He said he backs up every 1 minute, but when trouble arises, I sometimes goes back to almost 10 minutes ago. (Why?)

    To solve this problem, I would like to create a script that automatically does a command + s every minute as a simplified version for now.

    Here are the current works

    
    var pollingIntervalMs = 60000;
    
    
    sf.engine.runInBackground(function () {
    
    
        while (true) {
      
            sf.engine.checkForCancellation();
    
            if (sf.ui.proTools.mainWindow.invalidate().sessionPath !== null) {
                sf.keyboard.press({
                    keys: "cmd+s",
                });
            }
            
            sf.wait({
                intervalMs: pollingIntervalMs,
                executionMode: 'Background'
            });
        }
    
    });
    
    
    

    As it is, I would like to stop this script when I focus on an application other than Pro tools, because it tries to press ⌘ + S even when I am working in the Finder.

    And I think it would work if I make the trigger of this loop script to activate Pro tools.

    Please give me some advice!

    Best

    • 3 replies
    1. Hey @Yujiro_Yonetsu,

      Add this at the beginning of the while loop to stop the script if Pro Tools is not the focused app.

      if (sf.ui.frontmostApp.activeBundleID !== "com.avid.ProTools") return;
      
      1. ^^This

        And, I would recommend using a menu click on File -> Save instead of simulating a keystroke. (This would actually also alleviate the need to bypass this when PT is not focused)

        1. Yujiro Yonetsu @Yujiro_Yonetsu
            2022-05-28 16:52:07.712Z

            Thank you @raphaelsepulveda @chrscheuer !

            Worked fine. It's perfect, thank you.
            By making it menu click,
            I had avoided it because I thought it would be disturbing if the menu was momentarily expanded each time,
            but I tried it and was able to do it without the menu being expanded.
            This is better.

            Now that the idea has died out once and for all for development from here,
            I'll just use it as is for the next few days.

            Best!