No internet connection
  1. Home
  2. Macro and Script Help

Selecting Multiple Pro Tools Tracks and Cascading Inputs

By DeLaVanta Tabor @DeLaVanta_Tabor
    2022-05-05 02:29:13.390Z

    Title

    Selecting Multiple Pro Tools Tracks and Cascading Inputs

    What do you expect to happen when you run the script/macro?

    I would like for it to select all the listed tracks, which it does. Then I want it to use the cascade shortcut (Shift + opt + CMD) to select the input on the first selected track.

    Are you seeing an error?

    04.05.2022 22:24:54.76 [Backend]: !! Command Error: Drum Tracking Prep [user:default:cl2sd5s510006je10wa72hvg1]: Could not select input menu item: 'MP8R-1 1 (Mono)' (Drum Tracking Prep: Line 10) Could not click popup menu item Could not find menu item with name: MP8R-1 1 (Mono)

    What happens when you run this script?

    It gets all the way to trying to select the input and then it seems that it cant find it even though I have named it exactly the same as it shows in the list.

    How were you running this script?

    I used a Stream Deck button

    How important is this issue to you?

    4

    Details

    {
        "inputExpected": "I would like for it to select all the listed tracks, which it does.  Then I want it to use the cascade shortcut (Shift + opt + CMD) to select the input on the first selected track.",
        "inputIsError": true,
        "inputError": "04.05.2022 22:24:54.76  [Backend]: !! Command Error: Drum Tracking Prep [user:default:cl2sd5s510006je10wa72hvg1]:\nCould not select input menu item: 'MP8R-1 1 (Mono)' (Drum Tracking Prep: Line 10)\n    Could not click popup menu item\n    Could not find menu item with name: MP8R-1 1 (Mono)\n",
        "inputWhatHappens": "It gets all the way to trying to select the input and then it seems that it cant find it even though I have named it exactly the same as it shows in the list.",
        "inputHowRun": {
            "key": "-MpfwmPg-2Sb-HxHQAff",
            "title": "I used a Stream Deck button"
        },
        "inputImportance": 4,
        "inputTitle": "Selecting Multiple  Pro Tools Tracks and Cascading Inputs"
    }

    Source

    sf.ui.proTools.trackSelectByName({ deselectOthers: true, names: ['BD (In)','BD (Out)','Snr (T)','Snr (Btm)','Tom 1','Tom 2','Tom 3','OH.L','OH.R','Ride','HH'] });
    
    
    sf.keyboard.modifiers({
        isCommand: true,
        isOption: true,
        isShift: true,
    });
    
    sf.ui.proTools.selectedTrack.trackInputSelect({
        inputPath: ["MP8R-1 1 (Mono)"],
    });
    
    
    
    
    
    
    
    
    
    
    

    Links

    User UID: 71SxSMPzX3gEHqAzb5gXgIERxrn2

    Feedback Key: sffeedback:71SxSMPzX3gEHqAzb5gXgIERxrn2:-N1H2Bc2BkoAjsHIIHjf

    Feedback ZIP

    Solved in post #16, click to view
    • 17 replies

    There are 17 replies. Estimated reading time: 11 minutes

    1. @DeLaVanta_Tabor, for inputs, try adding four spaces in front of the bus name, like so:

      sf.ui.proTools.selectedTrack.trackInputSelect({
          inputPath: ["    MP8R-1 1 (Mono)"],
      });
      
      1. DDeLaVanta Tabor @DeLaVanta_Tabor
          2022-05-05 03:02:23.086Z

          Thanks . I just tried it with 4, 3 ,and 5 spaces. Still didn't work.

          1. Ahh, sorry forgot to include an important detail. This has to contain the whole path the way it is on the Pro Tools menu, so for example, if this input is within the 'bus' category, you'd do this:

            sf.ui.proTools.selectedTrack.trackInputSelect({
                inputPath: ["bus", "    MP8R-1 1 (Mono)"],
            });
            1. DDeLaVanta Tabor @DeLaVanta_Tabor
                2022-05-05 03:18:37.288Z

                OK! We're almost there. It did the first track as it should, but it did not cascade. Makes me think it wasn't holding down the modifiers before setting the input.

                1. This approach should work better!

                  sf.ui.proTools.selectedTrack.inputPathButton.popupMenuSelect({
                      menuPath: ["bus", "    MP8R-1 1 (Mono)"],
                      isShift: true,
                      isOption: true,
                      isCommand: true
                  });
                  
                  1. DDeLaVanta Tabor @DeLaVanta_Tabor
                      2022-05-05 03:37:46.210Z

                      That breaks it from even setting the first one.

                      1. Your full script should look like below.

                        The only part I'm not sure about is your input menu path. Modify this line: menuPath: ["bus", " MP8R-1 1 (Mono)"], with your actual input menu path, like you did the first time it worked. Since these are drum tracks, I'm assuming these are inputs from your interface and not busses, so my example will fail on your system if you don't modify this.

                        const trackNames = ['BD (In)', 'BD (Out)', 'Snr (T)', 'Snr (Btm)', 'Tom 1', 'Tom 2', 'Tom 3', 'OH.L', 'OH.R', 'Ride', 'HH'];
                        
                        sf.ui.proTools.appActivateMainWindow();
                        sf.ui.proTools.mainWindow.invalidate();
                        
                        sf.ui.proTools.trackDeselectAll();
                        
                        // Making sure the first track is on screen
                        const firstTrack = sf.ui.proTools.trackGetByName({ name: trackNames[0] }).track;
                        firstTrack.trackSelect();
                        firstTrack.trackScrollToView();
                        
                        sf.ui.proTools.trackSelectByName({
                            names: trackNames.slice(1),
                            deselectOthers: false
                        });
                        
                        sf.ui.proTools.selectedTrack.inputPathButton.popupMenuSelect({
                            menuPath: ["bus", "    MP8R-1 1 (Mono)"],
                            isShift: true,
                            isOption: true,
                            isCommand: true
                        });
                        
                        1. DDeLaVanta Tabor @DeLaVanta_Tabor
                            2022-05-05 04:21:36.513Z

                            Thank you Raphael. I just shut down for the evening, so I will try this first thing in the morning. .

                            1. DDeLaVanta Tabor @DeLaVanta_Tabor
                                2022-05-05 19:08:50.042Z

                                Alright finally got into work and tested it, still only puts the input on the first track.

                                I'm really really new to scripting so I can only look at this "logically". I see that the modifier key commands are placed after there select input command, but the way Pro Tools works is those keys need to be pressed before clicking on the input path button.

                                1. Mmm.. that's odd.

                                  Yeah, I can see how you'd think that, but in this case the order you pass the arguments into the function wouldn't impact functionality. That gets handled by the code within the function.

                                  Let's try to see if we can get a simple version of this working on your system. Make a test session with just 3 mono tracks and run this:

                                  sf.ui.proTools.appActivateMainWindow();
                                  sf.ui.proTools.mainWindow.invalidate();
                                  
                                  sf.ui.proTools.selectedTrack.inputPathButton.popupMenuSelect({
                                      menuPath: ["bus", "    Bus 1 (Mono)"],
                                      isShift: true,
                                      isOption: true,
                                      isCommand: true
                                  });
                                  

                                  It should cascade the inputs from bus 1 to 3, like so:
                                  https://www.dropbox.com/s/e7xz8ghcvo5e3cv/Cascade Inputs Test Script.mov?raw=1

                                  Does that work? Fingers crossed it does. If not, then it might be best to report this as a bug. Depending on your macOS and PT version there might be something up.

                                  1. DDeLaVanta Tabor @DeLaVanta_Tabor
                                      2022-05-05 23:39:34.800Z

                                      Yes that worked!

                                      1. DDeLaVanta Tabor @DeLaVanta_Tabor
                                          2022-05-05 23:46:30.881Z

                                          Here's the error I see in the script builder

                                          1. Ok, awesome! Now that we know it works we can make our way back from here.

                                            The next step would be to modify the menuPath of that simple example to the input you actually want and see if that cascades the test audio tracks.

                                            If that works, then go ahead and try that code on the drum tracks, but without having SoundFlow pre-select them for you. Just select them yourself and run the code to see if it cascades.

                                            If you make it this far, then it would be a matter of putting back the code that selects the drum tracks and checking if that's the step that's making the cascade not happen.

                                            While testing this, always make sure that the first track of the selection is visible. If it's not on screen the script cannot click on the track's input button to open the menu, which will make it fail instantly. The longer script I showed you earlier on the thread has a remedy for this, but I don't want to bring that in until we can get the main functionality of this going on your system.

                                            Regarding that screenshot you posted, that's from a syntax error, I'm assuming it happened after modifying the code? Possibly the menuPath? My best guess without seeing the code is that you missed a comma at the end of the menu path.

                                            1. DDeLaVanta Tabor @DeLaVanta_Tabor
                                                2022-05-06 17:52:21.177Z

                                                IT WORKS!!!!!!! Did exactly what you said. Heres the code that worked. Now the only thing with this is that it only works with the Edit window.

                                                sf.ui.proTools.appActivateMainWindow();
                                                sf.ui.proTools.mainWindow.invalidate();
                                                sf.ui.proTools.trackSelectByName({ deselectOthers: true, names: ['BD (In)','BD (Out)','Snr (T)','Snr (Btm)','Tom 1','Tom 2','Tom 3','OH.L','OH.R','Ride','HH'] });
                                                sf.ui.proTools.selectedTrack.inputPathButton.popupMenuSelect({
                                                menuPath: ["interface", " MP8R-1 1 (Mono)"],
                                                isShift: true,
                                                isOption: true,
                                                isCommand: true
                                                });

                                                1. Ok, awesome!

                                                  Most scripts in SoundFlow only work on the Edit window but you can wrap it in a function that toggles to the Edit window, runs the script, then comes back to the Mix window, like so:

                                                  function doWithEditWin({ action }) {
                                                      sf.ui.proTools.appActivateMainWindow();
                                                      sf.ui.proTools.mainWindow.invalidate();
                                                  
                                                      const windowEditMenuItem = sf.ui.proTools.getMenuItem("Window", "Edit");
                                                      const isEditWin = windowEditMenuItem.isMenuChecked;
                                                  
                                                      if (!isEditWin) {
                                                          sf.ui.proTools.menuClick({
                                                              menuPath: ["Window", "Edit"],
                                                          });
                                                  
                                                          sf.waitFor({
                                                              callback: () => sf.ui.proTools.focusedWindow.title.invalidate().value.startsWith('Edit:'),
                                                              pollingInterval: 50
                                                          });
                                                      }
                                                  
                                                      try {
                                                          action();
                                                      } finally {
                                                          if (!isEditWin) {
                                                              sf.ui.proTools.menuClick({
                                                                  menuPath: ["Window", "Mix"],
                                                              });
                                                  
                                                              sf.waitFor({
                                                                  callback: () => sf.ui.proTools.focusedWindow.title.invalidate().value.startsWith('Mix:'),
                                                                  pollingInterval: 50
                                                              });
                                                          }
                                                      }
                                                  }
                                                  
                                                  doWithEditWin({
                                                      action: () => {
                                                          sf.ui.proTools.trackSelectByName({
                                                              deselectOthers: true,
                                                              names: ['BD (In)', 'BD (Out)', 'Snr (T)', 'Snr (Btm)', 'Tom 1', 'Tom 2', 'Tom 3', 'OH.L', 'OH.R', 'Ride', 'HH']
                                                          });
                                                  
                                                          sf.ui.proTools.selectedTrack.inputPathButton.popupMenuSelect({
                                                              menuPath: ["interface", "    MP8R-1 1 (Mono)"],
                                                              isShift: true,
                                                              isOption: true,
                                                              isCommand: true
                                                          });
                                                      }
                                                  });
                                                  
                                                  Reply1 LikeSolution
                                                  1. DDeLaVanta Tabor @DeLaVanta_Tabor
                                                      2022-05-09 16:16:03.586Z

                                                      Thank you so much Raphael!!! This is the one. This is my first time ever getting into scripting and you've helped me learned quite a bit.

                                                      1. Glad to hear it! Happy Soundflowing!