No internet connection
  1. Home
  2. How to

Transport Control on Pro Tools

By Max Bobo @Max_Bobo
    2022-02-11 10:45:29.441Z

    Hi everyone,

    I've been looking for a way to move precisely the playhead of Pro Tools with soundflow.

    I have tried macro / script to set a text value in the text field of the Main Counter:

    sf.ui.proTools.mainWindow.groups.whoseTitle.is("Counter Display Cluster").first.textFields.whoseTitle.is("Main Counter").first.elementSetTextFieldWithAreaValue({
        value: "10:00.000",
    });
    

    But this doesn't work:

    11.02.2022 10:50:04.71 <info> [Backend]: !! Command Error: Macro1 [user:ckzfcz12w00001i10xq76fhdd:ckzi8a8bs000g1i10yhq161ri]:
    Could not set text area value (Macro1: Line 2)
    

    And after checking the elements with the accessibility API, this "AXTextField" is not settable.

    Does anyone have a script or know a way to move the playhead to a precise position with soundflow ?

    That would be of great help, and if it is not possible, it is good to know also.

    Thank you very much in advance,
    Best

    Maxime

    • 6 replies
    1. M
      Max Bobo @Max_Bobo
        2022-02-11 15:49:38.926Z

        Hey back,

        I found how to do this, by clicking the element and entering a text:

        //Activate Pro Tools Main Window
        sf.ui.proTools.appActivateMainWindow();
        
        //Click on New Meter's first field. 
        sf.ui.proTools.mainWindow.groups.whoseTitle.is("Counter Display Cluster").first.textFields.whoseTitle.is("Main Counter").first.elementClick();
        
        //Type text
        sf.keyboard.type({
            text: "999",
        });
        

        My question is, how to format the text for it to actually work, because at the moment it just writes some dummy 999 at the end of the "Min:Secs" timestamp ?

        I'm thinking of maybe simulating a enter key at the end for the playhead to move..

        Thx
        Maxime

        1. In reply toMax_Bobo:

          @Max_Bobo Ah yes, these types of text fields are a bit tricky.

          Here's one way to set the Main Counter to a specific value in Min:Secs:

          /** @param {{ newValue: string }} arg - "00:00.000" format */
          function setMainCounterMinSecs({ newValue }) {
              sf.ui.proTools.appActivateMainWindow();
              
              sf.ui.proTools.mainCounterDoWithValue({
                  targetValue: "Min:Secs",
                  action: () => {
                      const values = newValue.match(/^(\d+):(\d+).(\d+)$/);
          
                      if (!values) throw 'Please enter Main Counter New Value in "00:00.000" format';
          
                      const mainCounter = sf.ui.proTools.mainWindow.counterDisplay.textFields.whoseTitle.is("Main Counter").first;
          
                      mainCounter.elementClick();
          
                      values.reverse().forEach((value, i, arr) => {
                          if (i === arr.length - 1) return;
                          sf.keyboard.press({ keys: "left" });
                          sf.keyboard.type({ text: value });
                      });
                      sf.keyboard.press({ keys: "return" });
                  }
              });
          }
          
          setMainCounterMinSecs({
              newValue: "10:00.000"
          });
          
          1. AAndreas Altmann @Andreas_Altmann
              2023-02-07 03:37:44.617Z

              Great! Is there a way to make it that I can enter the specific time or bar?
              Thanks a bunch!

              1. @Andreas_Altmann, here it is for Bars|Beats:

                // /** @param {{ newValue: string }} arg - "1|1|000" format */
                function setMainCounterBarsBeats({ newValue }) {
                    sf.ui.proTools.appActivateMainWindow();
                
                    sf.ui.proTools.mainCounterDoWithValue({
                        targetValue: "Bars|Beats",
                        action: () => {
                            const mainCounter = sf.ui.proTools.mainWindow
                                .counterDisplay.textFields.whoseTitle.is("Main Counter").first;
                            const values = newValue.match(/^(\d+)\|(\d)\|(\d+)$/);
                
                            if (!values) throw 'Please enter Main Counter New Value in "1|1|000" format';
                
                            mainCounter.elementClick();
                
                            values.slice(1).reverse().forEach((value) => {
                                sf.keyboard.press({ keys: "left" });
                                sf.keyboard.type({ text: value });
                            });
                
                            sf.keyboard.press({ keys: "return" });
                        }
                    });
                }
                
                setMainCounterBarsBeats({
                    newValue: "5|1|000" // Enter value here
                });
                
            • A
              In reply toMax_Bobo:
              Andreas Altmann @Andreas_Altmann
                2023-02-07 04:45:22.716Z

                Sorry, I'm looking for it to run like this: I press a stream deck button and I enter the time or bar number. I can change the scribt for the bar/time option, but I have problems writing script for the flexibility of entering the bar/time.
                Example: My clients usually give me mixing notes with Min:Sec so I'd like to enter that manually.
                I apologize and should have been more clearer...
                Thanks

                1. You should get the Scheps Offset counter in the store. It's made for exactly what you are trying to do
                  https://soundflow.org/store/pkg/counter-offset