No internet connection
  1. Home
  2. How to

ProTools 2024.10 Script error for enabling Input track

By Daniel Betancourt @Daniel_Betancourt6
    2024-11-14 20:23:23.648Z2024-11-14 20:26:28.643Z

    I have a script that enables record + input but the input is failing to be activated. The script enables Record in a MIDI track and also enables record and input in an Audio track to pass through the midi as audio. This is the script I use:

    const targetTrackName = "Footsteps 1";
    
    /**
     * @param {Object} obj
     * @param {AxPtTrackHeader} obj.track
     * @param {'Enable'|'Disable'|'Toggle'} [obj.targetValue]
     */
    function trackSetRecordEnable({ track, targetValue = "Toggle" }) {
        const btn = track.buttons.whoseTitle.is("Track Record Enable").first;
        const btnName = btn.title.invalidate().value;
    
        const isSelected = btn.value.invalidate().value === "on state";
    
        const clickButton = () => btn.elementClick({}, `Could not click the button titled ${btnName}.`);
    
        if (targetValue === "Enable" && !isSelected || targetValue === "Disable" && isSelected || targetValue === "Toggle") {
            clickButton();
        }
    }
    
    /**
     * @param {Object} obj
     * @param {AxPtTrackHeader} obj.track
     * @param {'Enable'|'Disable'|'Toggle'} [obj.targetValue]
     */
    function trackSetInputMonitor({ track, targetValue = "Toggle" }) {
        const btn = track.buttons.whoseTitle.is("TrackInput Monitor").first;
        const btnName = btn.title.invalidate().value;
    
        const isSelected = btn.value.invalidate().value === "on";
    
        const clickButton = () => btn.elementClick({}, `Could not click the button titled ${btnName}.`);
    
        if (targetValue === "Enable" && !isSelected || targetValue === "Disable" && isSelected || targetValue === "Toggle") {
            clickButton();
        }
    }
    
    function main() {
        sf.ui.proTools.appActivateMainWindow();
    
        // Invalidate the main window incase the tracks have changed
        sf.ui.proTools.mainWindow.invalidate();
    
        const track = sf.ui.proTools.trackGetByName({ name: targetTrackName }).track;
    
        // Enable Record on Track
        trackSetRecordEnable({ track, targetValue: "Enable", });
    
        // Enable Input monotoring on Track
        trackSetInputMonitor({ track, targetValue: "Enable", });
    }
    
    main();
    
    Solved in post #7, click to view
    • 9 replies
    1. Kitch Membery @Kitch2024-11-14 20:37:03.315Z

      Hi @Daniel_Betancourt6,

      In Pro Tools 2024.10, Avid changed the name of the UI Element under the hood for the Input Monitor.

      Replacing the trackSetInputMonitor function with this script should fix the issue.

      /**
       * @param {Object} obj
       * @param {AxPtTrackHeader} obj.track
       * @param {'Enable'|'Disable'|'Toggle'} [obj.targetValue]
       */
      function trackSetInputMonitor({ track, targetValue = "Toggle" }) {
          const btn = track.buttons.whoseTitle.startsWith("Input monitoring").first;
          const btnName = btn.title.invalidate().value;
      
          const isSelected = btn.value.invalidate().value === "on";
      
          const clickButton = () => btn.elementClick({}, `Could not click the button titled ${btnName}.`);
      
          if (targetValue === "Enable" && !isSelected || targetValue === "Disable" && isSelected || targetValue === "Toggle") {
              clickButton();
          }
      }
      

      Let me know if it works for you. :-)

      1. Thanks Kitch,
        It does not seem to work. I pasted your script on top of the TrackSetInputMonitor function, but it does not activate the input. Only the record.

        1. Kitch Membery @Kitch2024-11-14 21:41:12.790Z

          Hi @Daniel_Betancourt6,

          Hmmm, I must have made an error somewhere. I shall take another look this afternoon. :-)

          1. Kitch Membery @Kitch2024-11-14 21:43:36.131Z

            I think I only tested the function's targetValue set to"Toggle"...

            My bad. I shall report back this afternoon with a new and improved version. :-)

            1. Kitch Membery @Kitch2024-11-14 22:16:03.785Z

              Hi @Daniel_Betancourt6

              I just tested my code and it seems to be working.

              Just in case here is the full script.

              const targetTrackName = "Footsteps 1";
              
              /**
               * @param {Object} obj
               * @param {AxPtTrackHeader} obj.track
               * @param {'Enable'|'Disable'|'Toggle'} [obj.targetValue]
               */
              function trackSetRecordEnable({ track, targetValue = "Toggle" }) {
                  const btn = track.buttons.whoseTitle.is("Track Record Enable").first;
                  const btnName = btn.title.invalidate().value;
              
                  const isSelected = btn.value.invalidate().value === "on state";
              
                  const clickButton = () => btn.elementClick({}, `Could not click the button titled ${btnName}.`);
              
                  if (targetValue === "Enable" && !isSelected || targetValue === "Disable" && isSelected || targetValue === "Toggle") {
                      clickButton();
                  }
              }
              
              /**
               * @param {Object} obj
               * @param {AxPtTrackHeader} obj.track
               * @param {'Enable'|'Disable'|'Toggle'} [obj.targetValue]
               */
              function trackSetInputMonitor({ track, targetValue = "Toggle" }) {
                  const btn = track.buttons.whoseTitle.startsWith("Input monitoring").first;
                  const btnName = btn.title.invalidate().value;
              
                  const isSelected = btn.value.invalidate().value === "on";
              
                  const clickButton = () => btn.elementClick({}, `Could not click the button titled ${btnName}.`);
              
                  if (targetValue === "Enable" && !isSelected || targetValue === "Disable" && isSelected || targetValue === "Toggle") {
                      clickButton();
                  }
              }
              
              function main() {
                  sf.ui.proTools.appActivateMainWindow();
              
                  // Invalidate the main window incase the tracks have changed
                  sf.ui.proTools.mainWindow.invalidate();
              
                  const track = sf.ui.proTools.trackGetByName({ name: targetTrackName }).track;
              
                  // Enable Record on Track
                  trackSetRecordEnable({ track, targetValue: "Enable", });
              
                  // Enable Input monotoring on Track
                  trackSetInputMonitor({ track, targetValue: "Enable", });
              }
              
              main();
              
              1. Perfect! Now it works! Thanks so much!

                Reply1 LikeSolution
                1. Kitch Membery @Kitch2024-11-14 22:58:31.045Z

                  Awesome! Glad it worked. :-)

                  1. Bbenjamin.lemoine @benjamin_lemoine
                      2024-11-19 17:48:43.425Z

                      Hi Kitch, first of all thank you for your contribution !
                      Is there any solution to apply this script with a selection of track with inputName ?

                      1. Kitch Membery @Kitch2024-11-19 18:35:42.581Z

                        Hi @benjamin_lemoine,

                        Could you provide a bit more context about what you are trying to achieve and the manual steps you would take to achieve it? I think I understand, but additional details could clarify things further.