No internet connection
  1. Home
  2. How to

How to make a script to select next track or previous track in the mix window?

By John Costello @John_Costello
    2020-08-06 19:11:38.442Z

    I would love to be able to have Streamdeck keys move the track selection left and right. Then we could navigate to adjacent tracks in order to further modify their plugins and sends in the mix window.

    Thanks!

    JC3

    Solved in post #2, click to view
    • 10 replies
    1. Chris Shaw @Chris_Shaw2020-08-06 23:00:39.251Z2020-08-07 00:29:21.111Z

      Here you go:

      If more than one track is selected the it will move the the leftmost track.

      Move Left:

      const sup = sf.ui.proTools
      var allTracks = sup.trackGetVisibleTracks().names;
      var allTracksCount = allTracks.length
      var selTracks = sup.trackGetSelectedTracks().names;
      var currentTrack = selTracks[0]
      for (var i = 0; i < allTracksCount; i++) {
          if (allTracks[i].indexOf(currentTrack) == 0)
              break;
      }
      i = i-1;
      if (i<0) {throw 0}
      sup.trackSelectByName({
          names: [allTracks[i ]]
      })
      

      Move Right:

      const sup = sf.ui.proTools
      var allTracks = sup.trackGetVisibleTracks().names;
      var allTracksCount = allTracks.length
      var selTracks = sup.trackGetSelectedTracks().names;
      var currentTrack = selTracks[0]
      for (var i = 0; i < allTracksCount; i++) {
          if (allTracks[i].indexOf(currentTrack) == 0)
              break;
      }
      i = i + 1;
      if (i > allTracksCount - 1) { throw 0 }
      sup.trackSelectByName({
          names: [allTracks[i]]
      });
      
      
      Reply2 LikesSolution
      1. The drawback of this script is that if you select a track that is not in view, it will not scroll it into view but it will still select it

        1. John Costello @John_Costello
            2020-08-06 23:51:29.870Z

            Hi Chris it is wonderful to meet you! This is so cool and thank you so very much! It looks like both scripts are the same, however. I hate to ask, but I wish I knew which value to change to make the "move track select to the right" script work correctly.

            Thank you again!

            JC3

            1. I fixed it. should work now.

              1. John Costello @John_Costello
                  2020-08-07 00:16:04.380Z

                  I feel so helpless not knowing how to fix this for myself, but it still moves to the left... I have restarted SF but not my machine yet...

                  1. My Bad. I fixed it again.
                    See Above

                    1. John Costello @John_Costello
                        2020-08-07 00:35:43.600Z

                        You are amazing!!!!! I will have so much fun with this script! When I'm in a section with a lot of tracks, such as percussion, I can now move around and make adjustments without having to click! Thank you for saving me!

                        1. In reply toChris_Shaw:

                          If you want the tracks to scroll when you get to the far left or far right just add this to the bottom of each script. It will open the comments view and (unfortunately) slow the script down a bit.

                           // This will scroll the tracks as after you get to the sides of the mix window
                          sf.ui.proTools.menuClick({
                              menuPath: ["View","Mix Window Views","Comments"],
                              targetValue: "Enable",
                          });
                          try {
                              sf.ui.proTools.windows.whoseTitle.contains('Mix:').first.groups.whoseTitle.contains(allTracks[i])
                                  .first.textFields.whoseTitle.is('Comments ""').first.elementClick();
                          
                              sf.keyboard.press({
                                  keys: "escape",
                              });
                          } catch (err) {
                              throw 0
                          }
                          
                          1. John Costello @John_Costello
                              2020-08-07 01:21:00.817Z

                              How cool! Even better! Thank you Chris!

                  2. In reply toChris_Shaw:
                    Yujiro Yonetsu @Yujiro_Yonetsu
                      2021-04-25 04:21:18.975Z

                      Hello @Chris_Shaw
                      This script has helped me a lot. Thank you very much.

                      However, "move to the right" often does not work.
                      In addition, "Move Left" may also stop at certain tracks.

                      I don't even get an error message, so I don't know, is there a possible cause?