No internet connection
  1. Home
  2. How to

How to move slots

By Giuliano Sulzberger @Giuliano_Sulzberger
    2020-04-18 16:36:55.878Z
    Is there a way to move slots on to a different slot in Pro Tools?
    • 37 replies

    There are 37 replies. Estimated reading time: 39 minutes

    1. @Giuliano_Sulzberger - can you elaborate on your question?

      Are you talking about insert slots? At this time we don't have a script to do that.
      Perhaps somebody would be interested in trying it out - it would involve simulating mouse drags.

      1. Kitch Membery @Kitch2020-04-19 11:01:00.840Z2020-04-19 11:17:36.364Z

        Hi @Giuliano_Sulzberger & @chrscheuer,

        I thought I might give this one a go, assuming you are talking about insert slots.

        The following script should do the trick (It could however use some code improvments, clearer variable names & testing but it works)... It is currently set up to switch or move "Insert A" to "Insert B".

        Please Note... You must have one insert slot free and the track height must be set to medium height or larger for the script to work.

        insertSlotSwitcher("Insert A", "Insert B");
        
        function insertSlotSwitcher(slotToMove, destinationSlot) {
        
            const pluginInsertArray = [
                { id: "Insert A", x: 290, y: 10 },
                { id: "Insert B", x: 290, y: 28 },
                { id: "Insert C", x: 290, y: 46 },
                { id: "Insert D", x: 290, y: 64 },
                { id: "Insert E", x: 290, y: 82 },
                { id: "Insert F", x: 360, y: 10 },
                { id: "Insert G", x: 360, y: 28 },
                { id: "Insert H", x: 360, y: 46 },
                { id: "Insert I", x: 360, y: 64 },
                { id: "Insert J", x: 360, y: 82 },
            ];
        
            //"Slot to Move" Item and X,Y values
            const slotToMoveItem = pluginInsertArray.findIndex(item => item.id === slotToMove);
            var originX = pluginInsertArray[slotToMoveItem].x;
            var originY = pluginInsertArray[slotToMoveItem].y;
        
            //"Destination Slot" Item and X,Y values
            const destinationSlotItem = pluginInsertArray.findIndex(item => item.id === destinationSlot);
            var destinationX = pluginInsertArray[destinationSlotItem].x;
            var destinationY = pluginInsertArray[destinationSlotItem].y;
        
            //Locate "First Free Insert Slot"
            function getFirstFreeInsertIndex() {
                var btns = sf.ui.proTools.selectedTrack.invalidate().insertButtons;
                for (var i = 0; i < 10; i++)
                    if (btns[i].value.invalidate().value === "unassigned") return i;
                throw 0;
            }
        
            //"First Free Insert Slot" X,Y values
            const firstFreeX = pluginInsertArray[getFirstFreeInsertIndex()].x;
            const firstFreeY = pluginInsertArray[getFirstFreeInsertIndex()].y;
        
            function dragInsert(fromX, fromY, toX, toY) {
                var trackFrame = sf.ui.proTools.mainWindow.groups.allItems[7].frame;
        
                sf.mouse.simulateDrag({
                    startPosition: { "x": trackFrame.x + fromX, "y": trackFrame.y + fromY },
                    endPosition: { "x": trackFrame.x + toX, "y": trackFrame.y + toY },
                });
            }
        
            //If "Slot To Move" is unassigned cancel script
            if (sf.ui.proTools.selectedTrack.insertButtons[slotToMoveItem].value.value === "unassigned") {
                throw (0);
            }
        
            //If "Destination Slot" is unassigned
            if (sf.ui.proTools.selectedTrack.insertButtons[destinationSlotItem].value.value === "unassigned") {
                //Move "Slot to Move" to "Destination Slot"
                dragInsert(originX, originY, destinationX, destinationY);
            } else {
                //Move "Destination Slot" to "First Free Insert Slot"
                dragInsert(destinationX, destinationY, firstFreeX, firstFreeY);
        
                //Move "Slot to Move" to "Destination Slot"
                dragInsert(originX, originY, destinationX, destinationY);
        
                //Move "First Free Slot" to "Original Slot"
                dragInsert(firstFreeX, firstFreeY, originX, originY);
            };
        }
        

        Rock on!

        1. Cool work Kitch :)
          Make sure to read my post in the other thread here about how to not use relative positions but instead grab the buttons themselves:
          https://forum.soundflow.org/-1918/simulate-mouse-drag-from-relative-ui-position#post-5

          1. In reply toKitch:
            Andrew Scheps @Andrew_Scheps
              2020-04-22 14:14:59.952Z

              Here's the way I free up the first insert slot. Pretty similar but maybe a couple different ways to do things. Some copy and paste from Christian may have happened along the way...

              /* 
              This script will open up insert slot 1 on the selected tracks by finding the first empty slot and dragging all plugins down until 1 is open.
              
              */
              sf.ui.proTools.appActivateMainWindow();
              
              function waitForResponsive(timeout) {
                  var pollingInterval = 200;
                  var waitedTime = 0;
                  while (true) {
                      sf.engine.checkForCancellation();
                      try {
                          var val = sf.ui.proTools.mainWindow.title.invalidate().value;
                          return true;
                      } catch (err) {
                      }
                      if (timeout > 0 && waitedTime >= timeout)
                          throw 'Timeout in waiting for Pro Tools to become responsive';
                      sf.wait({ intervalMs: pollingInterval });
                      waitedTime += pollingInterval;
                  }
              }
              // Moves inserts to the left of the first free insert one slot later to free up slot 1
              function makeRoomForInsert(emptySLot) {
                  var sourceInsertXY, destInsertXY;
              
                  for (i = emptySLot; i > 0; i--) {
                      destInsertXY = sf.ui.proTools.mainWindow.groups.whoseTitle.is(targetTrack + ' - Audio Track ').first.groups.whoseTitle.is(insertSlots[i][1]).first.buttons.whoseTitle.is('Insert Assignment ' + insertSlots[i][0]).first.position;
                      sourceInsertXY = sf.ui.proTools.mainWindow.groups.whoseTitle.is(targetTrack + ' - Audio Track ').first.groups.whoseTitle.is(insertSlots[i - 1][1]).first.buttons.whoseTitle.is('Insert Assignment ' + insertSlots[i - 1][0]).first.position;
                      sf.mouse.simulateDrag({
                          startPosition: { "x": (sourceInsertXY.x + 2), "y": (sourceInsertXY.y + 5) },
                          endPosition: { "x": (destInsertXY.x + 2), "y": (destInsertXY.y + 5) }
                      });
                      waitForResponsive(10000); //Allow for slow-instantiating plugins
                      //log("Moved insert " + i);
                  }
              }
              
              
              // ---------- Initialise Variables ---------------
              // Refresh PTs track list
              sf.ui.proTools.mainWindow.invalidate();
              var insertSlots = new Array(10);                                                // Array holding text for coordinate hunting later                                                
              for (var i = 0; i < insertSlots.length; i++) {
                  insertSlots[i] = [];
              }
              for (i = 0; i < insertSlots.length; i++) {
                  insertSlots[i][0] = String.fromCharCode(i + 65);
                  if (i < 5) {
                      insertSlots[i][1] = "Inserts A-E";
                  } else { insertSlots[i][1] = "Inserts F-J"; }
              }
              var trackCount = sf.ui.proTools.selectedTrackCount;
              var trackList = sf.ui.proTools.selectedTrackNames;
              
              // Set up screen
              //Close all floating windows
              sf.ui.proTools.viewCloseFloatingWindows();
              
              //Make sure Inserts are visible in Edit wondow
              sf.ui.proTools.menuClick({
                  menuPath: ["View", "Edit Window Views", "Inserts F-J"],
                  targetValue: "Enable",
              });
              sf.ui.proTools.menuClick({
                  menuPath: ["View", "Edit Window Views", "Inserts A-E"],
                  targetValue: "Enable",
              });
              
              for (var j = 0; j < trackCount; j++) {
                  var firstFreeInsert = -1;                                       // Holds the first free insert number if there is any, initialized to -1 which is no fre insert
                  var targetTrack = trackList[j];                                 // Selected track name for later
              
                  sf.ui.proTools.trackGetByName({ name: targetTrack, makeVisible: true }).track.trackSelect();
              
                  var currentInserts = sf.ui.proTools.selectedTrack.invalidate().insertButtons;  // Array to hold the names of the existing inserts so we can find an unassigned slot
                  // Find out if there is a free insert slot and assign the first free slot number to a variable
                  for (var i = 0; i < 10; i++) {
                      if (currentInserts[i].value.invalidate().value === 'unassigned') {
                          firstFreeInsert = i;
                          break
                      }
                  };
                  // Make sure there's a free insert slot somewhere
                  if (firstFreeInsert == -1) {
                      log("Track: " + targetTrack + " has no free insert slots");
                      throw (0)
                  };
                  // If the free slot isn't slot 0 then move plugins to free up slot 0
              
                  if (firstFreeInsert != 0) {
                      makeRoomForInsert(firstFreeInsert);
                  };
              }
              
              
              
              1. Hmm. This script is throwing an error for me "Source insert xy is null - Line 31

                1. Andrew Scheps @Andrew_Scheps
                    2020-04-22 17:16:08.665Z

                    Hmmm, working for me. It's built to work in the Edit window on audio tracks and you need all 10 insert slots showing. I should expand the scope to include Auxes and Master Faders but I wasn't planning on letting out into the wild yet.

                    1. SSreejesh Nair @Sreejesh_Nair2
                        2020-04-22 19:44:45.463Z

                        Same foe me as well. For some reason sourceInsertXY and destInsertXY turn up as null.

                        1. Andrew Scheps @Andrew_Scheps
                            2020-04-22 19:55:35.599Z

                            You're definitely doing it with an audio track selected?

                            1. Kitch Membery @Kitch2020-04-23 06:01:42.523Z

                              Nice one Andrew!! That script will be super handy for melodyne or denoise inserts!

                              BTW It works for me. :-)

                              1. Andrew Scheps @Andrew_Scheps
                                  2020-04-23 08:17:55.196Z

                                  Well let's try and figure out why it's not working for Chris and Sreejesh. Could it be a Pro Tools version issue? I'm on the latest.

                                  1. Kitch Membery @Kitch2020-04-23 08:53:50.953Z

                                    I'm on the latest 2020.3.0 as well.

                                    1. One immediate thing I can think of is if people are having different track heights when using this script, the layouts may be different, and there may be certain assumptions made in the script that are not met when running the script.
                                      A quick screen recording from those where it doesn't work often is the quickest way to identify what goes wrong and why :)

                                      1. Andrew Scheps @Andrew_Scheps
                                          2020-04-23 16:55:26.507Z

                                          I tested at all track heights and that's not a problem, but I'm sure there's something else I'm assuming. A screen record would be awesome.

                      • @Giuliano_Sulzberger were you able to use @Kitch's solution?

                        1. As asked, here is a screen recording of Andrew's script not working. I assigned his script to ctl-opt-cmd-T.
                          I set the track height to medium then execute the script. It throws an error on line 31.
                          Hope this helps

                          1. Andrew Scheps @Andrew_Scheps
                              2020-04-30 20:29:45.444Z

                              I've found the underlying problem with the script. Showing track numbers adds the number to the text SF needs when trying to select a track, but it doesn't add it to the names Pro Tools reports to SF so there's a mismatch. For this to work for now, as Sreejesh found, you have to turn off track numbers.

                              1. Ahhh, there you go!

                                I would suggest a modified version of this script if possible. It'd be great if you selected any plugin/insert loacation and then the script would move the selcted insert and all those proceeding them down one slot. This way you can insert a new plugin between two adjacent slots that are occupied.

                                Any takers? :)

                                1. Andrew Scheps @Andrew_Scheps
                                    2020-04-30 21:11:38.665Z

                                    Do you have a Stream Deck yet? I have a script that lets you you pick an insert slot to instantiate a plugin on by displaying the inserts on the Deck, then you push the button for the slot you want. This could easily be modified to select the slot you want to open up (if possible). I have a lot of plans for this kind of stuff.

                                    I suppose the other thing is you could check to see which insert slot the mouse was hovered over when you trigger the script, but that seem fraught with danger and would probably break a lot.

                                    1. Haven't gotten a stream deck yet - waiting to see what the SF iOS app will do. (In the meantime I'm assigning crazy key combos to my scripts and then triggering them with softkeys in the AVID Controll app. It's prety easy to set up submenus on it too.)

                                      Anyway…

                                      Instead of checking which slot the mouse is hovering over perhaps a user would just open the plugin on the insert that he wants to move, thenSF could query which plugin window/slot is open and then free up that slot.

                                      I have the OmniChannel at the end of my plugin chain. It's my "I give up. What would Scheps do?" solution…

                                2. In reply toChris_Shaw:
                                  Andrew Scheps @Andrew_Scheps
                                    2020-04-30 21:13:00.961Z

                                    (and thanks for instantiating those OmniChannels for the video, now un-bypass them!)

                                    1. Or how about opening an alert / dialog window at the start of the script that asks the user to enter the slot letter or number he wants to free up? OR an alert box that asks the user "Place the mouse cursor over the slot that needs to be freed up" with an OK button. Then it's off to the races…

                                      1. Andrew Scheps @Andrew_Scheps
                                          2020-04-30 21:34:43.328Z

                                          I think the dialog is definitely the way to go without a StreamDeck. The logic get's a little trickier though since we might be dragging plugins to lower numbered slots as well as higher number. I'll get something though!

                                          1. In reply toChris_Shaw:
                                            Andrew Scheps @Andrew_Scheps
                                              2020-04-30 21:38:13.910Z

                                              And... What if there are plugins in slots 2,3 and 4 and you want to put something between slots 2 and 3? Should it drag 3 and 4 down to 4 and 5 (which is probably my preference) or should it drag 2 to 1 which is less work? I have a feeling the easiest way to do it is to see if you can drag things to later slots and if you can't then see if you can drag them to earlier slots. Either way I need a little more brain power than I have right now to do it, but I'm definitely going to do it!

                                              1. Agreed, everything should move down unless there's nothing free below the selected slot then the script should move the selected plugin and (everything above it) up.

                                                OK, for real, back to work… :)

                                        • S
                                          Sreejesh Nair @Sreejesh_Nair2
                                            2020-04-30 08:41:09.224Z2020-04-30 22:55:38.180Z

                                            I figured why this wasnt working. I was showing track numbers. When that is done, the sourceInsertXY shows up only the track name without the track number, while if the track number was showing it would have to be part of the name to reference the track. Thanks. I have added that check to the beginning of the script and will reset your view once the script has run.

                                            /*This script will open up insert slot 1 on the selected tracks by finding the first empty slot and dragging all plugins down until 1 is open.
                                            
                                            */
                                            sf.ui.proTools.appActivateMainWindow();
                                            
                                            var numEnab = 0
                                            var tNum = sf.ui.proTools.getMenuItem('View', 'Track Number').isMenuChecked;
                                            if (tNum) {
                                                numEnab = 1;
                                                sf.ui.proTools.menuClick({
                                                    menuPath: ["View", "Track Number"],
                                                });
                                            }
                                            
                                            
                                            function waitForResponsive(timeout) {
                                                var pollingInterval = 200;
                                                var waitedTime = 0;
                                                while (true) {
                                                    sf.engine.checkForCancellation();
                                                    try {
                                                        var val = sf.ui.proTools.mainWindow.title.invalidate().value;
                                                        return true;
                                                    } catch (err) {
                                                    }
                                                    if (timeout > 0 && waitedTime >= timeout)
                                                        throw 'Timeout in waiting for Pro Tools to become responsive';
                                                    sf.wait({ intervalMs: pollingInterval });
                                                    waitedTime += pollingInterval;
                                                }
                                            }
                                            // Moves inserts to the left of the first free insert one slot later to free up slot 1
                                            function makeRoomForInsert(emptySLot) {
                                                var sourceInsertXY, destInsertXY;
                                            
                                            
                                                for (i = emptySLot; i > 0; i--) {
                                                    destInsertXY = sf.ui.proTools.mainWindow.groups.whoseTitle.is(targetTrack + ' - Audio Track ').first.groups.whoseTitle.is(insertSlots[i][1]).first.buttons.whoseTitle.is('Insert Assignment ' + insertSlots[i][0]).first.position;
                                                    sourceInsertXY = sf.ui.proTools.mainWindow.groups.whoseTitle.is(targetTrack + ' - Audio Track ').first.groups.whoseTitle.is(insertSlots[i - 1][1]).first.buttons.whoseTitle.is('Insert Assignment ' + insertSlots[i - 1][0]).first.position;
                                            
                                            
                                                    sf.mouse.simulateDrag({
                                                        startPosition: { "x": (sourceInsertXY.x + 2), "y": (sourceInsertXY.y + 5) },
                                                        endPosition: { "x": (destInsertXY.x + 2), "y": (destInsertXY.y + 5) }
                                                    });
                                                    waitForResponsive(10000); //Allow for slow-instantiating plugins
                                                    //log("Moved insert " + i);
                                                }
                                            }
                                            
                                            
                                            // ---------- Initialise Variables ---------------
                                            // Refresh PTs track list
                                            sf.ui.proTools.mainWindow.invalidate();
                                            var insertSlots = new Array(10);                                                // Array holding text for coordinate hunting later                                                
                                            for (var i = 0; i < insertSlots.length; i++) {
                                                insertSlots[i] = [];
                                            }
                                            for (i = 0; i < insertSlots.length; i++) {
                                                insertSlots[i][0] = String.fromCharCode(i + 65);
                                                if (i < 5) {
                                                    insertSlots[i][1] = "Inserts A-E";
                                                } else { insertSlots[i][1] = "Inserts F-J"; }
                                            }
                                            var trackCount = sf.ui.proTools.selectedTrackCount;
                                            var trackList = sf.ui.proTools.selectedTrackNames;
                                            
                                            // Set up screen
                                            //Close all floating windows
                                            sf.ui.proTools.viewCloseFloatingWindows();
                                            
                                            //Make sure Inserts are visible in Edit wondow
                                            sf.ui.proTools.menuClick({
                                                menuPath: ["View", "Edit Window Views", "Inserts F-J"],
                                                targetValue: "Enable",
                                            });
                                            sf.ui.proTools.menuClick({
                                                menuPath: ["View", "Edit Window Views", "Inserts A-E"],
                                                targetValue: "Enable",
                                            });
                                            
                                            for (var j = 0; j < trackCount; j++) {
                                                var firstFreeInsert = -1;                                       // Holds the first free insert number if there is any, initialized to -1 which is no fre insert
                                                var targetTrack = trackList[j];
                                                //log(targetTrack + ' - Audio Track ')                             // Selected track name for later
                                            
                                                sf.ui.proTools.trackGetByName({ name: targetTrack, makeVisible: true }).track.trackSelect();
                                            
                                                var currentInserts = sf.ui.proTools.selectedTrack.invalidate().insertButtons;  // Array to hold the names of the existing inserts so we can find an unassigned slot
                                                // Find out if there is a free insert slot and assign the first free slot number to a variable
                                                for (var i = 0; i < 10; i++) {
                                                    if (currentInserts[i].value.invalidate().value === 'unassigned') {
                                                        firstFreeInsert = i;
                                                        break
                                                    }
                                                };
                                                // Make sure there's a free insert slot somewhere
                                                if (firstFreeInsert == -1) {
                                                    log("Track: " + targetTrack + " has no free insert slots");
                                                    throw (0)
                                                };
                                                // If the free slot isn't slot 0 then move plugins to free up slot 0
                                            
                                                if (firstFreeInsert != 0) {
                                                    makeRoomForInsert(firstFreeInsert);
                                                };
                                            }
                                            
                                            if (numEnab) {
                                                sf.ui.proTools.menuClick({
                                                    menuPath: ["View", "Track Number"],
                                                });
                                            }
                                            
                                            1. This script works great!
                                              However you should edit your post. it's mising a "/*" at the very begining…

                                              1. SSreejesh Nair @Sreejesh_Nair2
                                                  2020-04-30 22:55:58.560Z

                                                  Thanks! Done. Was probably a copy paste error!

                                              2. Andrew Scheps @Andrew_Scheps
                                                  2020-04-30 21:23:35.470Z2020-04-30 21:33:15.258Z

                                                  EDIT: If you copied the script in the last 20 minutes use this instead. Much simpler.

                                                  Ok, thanks to Christian, here's a version that works with or without track numbers. With some modification you could specify a constant that will select which slot you want to open up, then you can just make 9 copies of the script with different constants and assign them to different key commands. Or add a dialog to the script that asks which slot you want to free up. I can have a look at this in the next few days. Would definitely be more useful.

                                                  /* 
                                                  This script will open up insert slot 1 on the selected tracks by finding the first empty slot and dragging all plugins down until 1 is open.
                                                  
                                                  */
                                                  sf.ui.proTools.appActivateMainWindow();
                                                  
                                                  function waitForResponsive(timeout) {
                                                      var pollingInterval = 200;
                                                      var waitedTime = 0;
                                                      while (true) {
                                                          sf.engine.checkForCancellation();
                                                          try {
                                                              var val = sf.ui.proTools.mainWindow.title.invalidate().value;
                                                              return true;
                                                          } catch (err) {
                                                          }
                                                          if (timeout > 0 && waitedTime >= timeout)
                                                              throw 'Timeout in waiting for Pro Tools to become responsive';
                                                          sf.wait({ intervalMs: pollingInterval });
                                                          waitedTime += pollingInterval;
                                                      }
                                                  }
                                                  // Moves inserts to the left of the first free insert one slot later to free up slot 1
                                                  function makeRoomForInsert(emptySLot) {
                                                      var sourceInsertXY, destInsertXY;
                                                  
                                                      for (i = emptySLot; i > 0; i--) {
                                                          destInsertXY = sf.ui.proTools.trackGetByName({ name: targetTrack }).track.insertButtons[i].position
                                                          sourceInsertXY = sf.ui.proTools.trackGetByName({ name: targetTrack }).track.insertButtons[i - 1].position
                                                          sf.mouse.simulateDrag({
                                                              startPosition: { "x": (sourceInsertXY.x + 2), "y": (sourceInsertXY.y + 5) },
                                                              endPosition: { "x": (destInsertXY.x + 2), "y": (destInsertXY.y + 5) }
                                                          });
                                                          waitForResponsive(10000); //Allow for slow-instantiating plugins
                                                          //log("Moved insert " + i);
                                                      }
                                                  }
                                                  
                                                  
                                                  // ---------- Initialise Variables ---------------
                                                  // Refresh PTs track list
                                                  sf.ui.proTools.mainWindow.invalidate();
                                                  
                                                  var trackCount = sf.ui.proTools.selectedTrackCount;
                                                  var trackList = sf.ui.proTools.selectedTrackNames;
                                                  
                                                  // Set up screen
                                                  //Close all floating windows
                                                  sf.ui.proTools.viewCloseFloatingWindows();
                                                  
                                                  //Make sure Inserts are visible in Edit window
                                                  sf.ui.proTools.menuClick({
                                                      menuPath: ["View", "Edit Window Views", "Inserts F-J"],
                                                      targetValue: "Enable",
                                                  });
                                                  sf.ui.proTools.menuClick({
                                                      menuPath: ["View", "Edit Window Views", "Inserts A-E"],
                                                      targetValue: "Enable",
                                                  });
                                                  
                                                  for (var j = 0; j < trackCount; j++) {
                                                      var firstFreeInsert = -1;                                       // Holds the first free insert number if there is any, (initialized to -1 which is no free insert)
                                                      var targetTrack = trackList[j];                                 // Selected track name for later
                                                  
                                                      sf.ui.proTools.trackGetByName({ name: targetTrack, makeVisible: true }).track.trackSelect();
                                                  
                                                      var currentInserts = sf.ui.proTools.selectedTrack.invalidate().insertButtons;  // Array to hold the names of the existing inserts so we can find an unassigned slot
                                                      // Find out if there is a free insert slot and assign the first free slot number to a variable
                                                      for (var i = 0; i < 10; i++) {
                                                          if (currentInserts[i].value.invalidate().value === 'unassigned') {
                                                              firstFreeInsert = i;
                                                              break
                                                          }
                                                      };
                                                      // Make sure there's a free insert slot somewhere
                                                      if (firstFreeInsert == -1) {
                                                          log("Track: " + targetTrack + " has no free insert slots");
                                                          throw (0)
                                                      };
                                                      // If the free slot isn't slot 0 then move plugins to free up slot 0
                                                  
                                                      if (firstFreeInsert != 0) {
                                                          makeRoomForInsert(firstFreeInsert);
                                                      };
                                                  }
                                                  
                                                  
                                                  1. SSreejesh Nair @Sreejesh_Nair2
                                                      2020-05-01 10:17:45.991Z2020-05-01 10:24:48.691Z

                                                      This is cool! Although I did run into one issue I didnt notice before. This one does a close all floating windows. The problem with that is if you did a Command+Opt+Control+W before running the script, it will reopen all the floating windows back. Because that is like a toggle command for hide all floating windows. So maybe a check if there are any floating windows, and if so, close them and then make the move would be good I guess. :) Adding this at line 49 will help:

                                                      if (sf.ui.proTools.floatingWindows.exists) {
                                                          sf.ui.proTools.viewCloseFloatingWindows();
                                                      }
                                                      
                                                      1. Andrew Scheps @Andrew_Scheps
                                                          2020-05-01 11:55:39.402Z

                                                          Awesome, thanks for this.

                                                        • In reply toAndrew_Scheps:
                                                          Andrew Scheps @Andrew_Scheps
                                                            2020-05-01 18:28:41.852Z

                                                            Ok, here it is! This will free up whatever slot you specify in the dialog (using number 1 through 10). It will always attempt to move the existing inserts to the right first, and if there are no slots move them to the left.

                                                            /* 
                                                            This script will open up a user specified insert slot on the selected track by finding the first empty slot and dragging all plugins down until 1 is open.
                                                            
                                                            */
                                                            
                                                            
                                                            function waitForResponsive(timeout) {
                                                                var pollingInterval = 200;
                                                                var waitedTime = 0;
                                                                while (true) {
                                                                    sf.engine.checkForCancellation();
                                                                    try {
                                                                        var val = sf.ui.proTools.mainWindow.title.invalidate().value;
                                                                        return true;
                                                                    } catch (err) {
                                                                    }
                                                                    if (timeout > 0 && waitedTime >= timeout)
                                                                        throw 'Timeout in waiting for Pro Tools to become responsive';
                                                                    sf.wait({ intervalMs: pollingInterval });
                                                                    waitedTime += pollingInterval;
                                                                }
                                                            }
                                                            // Moves inserts to the right of the first free insert one slot later to free up slot 1
                                                            function dragInsertsAfterTarget(slots) {
                                                            
                                                                var sourceInsertXY, destInsertXY;
                                                            
                                                                for (var i = slots.free; i > slots.targetIndex; i--) {
                                                                    destInsertXY = sf.ui.proTools.trackGetByName({ name: targetTrack }).track.insertButtons[i].position
                                                                    sourceInsertXY = sf.ui.proTools.trackGetByName({ name: targetTrack }).track.insertButtons[i - 1].position
                                                            
                                                                    sf.mouse.simulateDrag({
                                                                        startPosition: { "x": (sourceInsertXY.x + 2), "y": (sourceInsertXY.y + 5) },
                                                                        endPosition: { "x": (destInsertXY.x + 2), "y": (destInsertXY.y + 5) }
                                                                    });
                                                                    waitForResponsive(10000); //Allow for slow-instantiating plugins
                                                                    //log("Moved insert " + i);
                                                                }
                                                            }
                                                            function dragInsertsBeforeTarget(slots) {
                                                                var sourceInsertXY, destInsertXY;
                                                                for (i = slots.free; i < slots.targetIndex; i++) {
                                                                    destInsertXY = sf.ui.proTools.trackGetByName({ name: targetTrack }).track.insertButtons[i].position
                                                                    sourceInsertXY = sf.ui.proTools.trackGetByName({ name: targetTrack }).track.insertButtons[i + 1].position
                                                                    sf.mouse.simulateDrag({
                                                                        startPosition: { "x": (sourceInsertXY.x + 2), "y": (sourceInsertXY.y + 5) },
                                                                        endPosition: { "x": (destInsertXY.x + 2), "y": (destInsertXY.y + 5) }
                                                                    });
                                                                    waitForResponsive(10000); //Allow for slow-instantiating plugins
                                                                    //log("Moved insert " + i);
                                                                }
                                                            }
                                                            function getCurrentInsertName(insert) {
                                                                return insert.value.invalidate().value
                                                            }
                                                            
                                                            
                                                            
                                                            // ---------- Initialise Variables ---------------
                                                            sf.ui.proTools.appActivateMainWindow();
                                                            // Refresh PTs track list
                                                            sf.ui.proTools.mainWindow.invalidate();
                                                            
                                                            var trackCount = sf.ui.proTools.selectedTrackCount;
                                                            var trackList = sf.ui.proTools.selectedTrackNames;
                                                            
                                                            // Set up screen
                                                            //Close all floating windows
                                                            if (sf.ui.proTools.floatingWindows.exists) {
                                                                sf.ui.proTools.viewCloseFloatingWindows();
                                                            }
                                                            
                                                            //Make sure Inserts are visible in Edit window
                                                            sf.ui.proTools.menuClick({
                                                                menuPath: ["View", "Edit Window Views", "Inserts F-J"],
                                                                targetValue: "Enable",
                                                            });
                                                            sf.ui.proTools.menuClick({
                                                                menuPath: ["View", "Edit Window Views", "Inserts A-E"],
                                                                targetValue: "Enable",
                                                            });
                                                            
                                                            for (var j = 0; j < trackCount; j++) {
                                                                var firstFreeInsert = -1;                                       // Holds the first free insert number if there is any, (initialized to -1 which is no free insert)
                                                                var targetTrack = trackList[j];                                 // Selected track name for later
                                                            
                                                                sf.ui.proTools.trackGetByName({ name: targetTrack, makeVisible: true }).track.trackSelect();
                                                            
                                                                var currentInserts = sf.ui.proTools.selectedTrack.invalidate().insertButtons;  // Array to hold the names of the existing inserts so we can find an unassigned slot
                                                                let currentInsertNames = currentInserts.map(getCurrentInsertName);
                                                            
                                                                let targetSlot = Number(sf.interaction.popupText({ title: 'Enter the Insert Slot number (1-10) you would like to free up' }).text);
                                                                if (currentInsertNames[targetSlot - 1] == 'unassigned') {       //insert slot already free
                                                                    break
                                                                }
                                                            
                                                                // Find out if there is a free insert slot after the target (preferable) and assign the first free slot number to a variable
                                                            
                                                                for (var i = targetSlot - 1; i < 10; i++) {
                                                                    if (currentInsertNames[i] == 'unassigned') {
                                                                        firstFreeInsert = i;
                                                                        break
                                                                    }
                                                                }
                                                                // There wasn'ta slot after so look before
                                                                if (firstFreeInsert == -1) {
                                                                    for (var i = targetSlot - 1; i > -1; i--) {
                                                                        if (currentInsertNames[i] == 'unassigned') {
                                                                            firstFreeInsert = i;
                                                                            break
                                                                        }
                                                                    };
                                                                }
                                                            
                                                                // Apparently there wasn't a slot open
                                                                if (firstFreeInsert == -1) {
                                                                    log("Track: " + targetTrack + " has no free insert slots");
                                                                    throw (0)
                                                                };
                                                            
                                                                // If there is a free slot after the target then drag inserts later
                                                            
                                                                if (firstFreeInsert > targetSlot - 1) {
                                                                    dragInsertsAfterTarget({ targetIndex: targetSlot - 1, free: firstFreeInsert });
                                                                } else { dragInsertsBeforeTarget({ targetIndex: targetSlot - 1, free: firstFreeInsert }) }
                                                            }
                                                            
                                                            
                                                            1. Andrew Scheps @Andrew_Scheps
                                                                2020-05-01 18:29:21.207Z

                                                                I'll eventually do a version that shows the existing inserts on the stream deck and you can just click the slot you want open

                                                                1. In reply toAndrew_Scheps:
                                                                  S2Stewart Geddes @Stewart_Geddes
                                                                    2023-06-02 05:38:22.772Z

                                                                    Hey @Andrew_Scheps or anyone else who can help me here - how can I make this script always free up insert #10 (j)? Without having to specify plugin slot in the dialog.

                                                                    1. Andrew Scheps @Andrew_Scheps
                                                                        2023-06-02 10:20:03.984Z

                                                                        Change line 92:

                                                                        let targetSlot = Number(sf.interaction.popupText({ title: 'Enter the Insert Slot number (1-10) you would like to free up' }).text);
                                                                        

                                                                        to

                                                                        let targetSlot = 10;
                                                                        
                                                                        1. S2Stewart Geddes @Stewart_Geddes
                                                                            2023-06-02 10:57:57.143Z

                                                                            Too good, thanks so much Andrew!!

                                                                    2. G
                                                                      Garrett Atkinson @Garrett_Atkinson
                                                                        2021-08-12 19:00:16.326Z

                                                                        @Andrew_Scheps Okay so once I've committed Melodyne, insert slot A is now free. When using my macros to add a plugin, it'll add it to the next available slot which is slot A. But I've already got plugins on B and C. Is there a script for moving all the plugins up 1? Like sliding them all up so insert A is now taken and when I click on my plugin macros it'll fall to next in line not go to the top and I won't have to individually drag each plugin to the top?

                                                                        1. Andrew Scheps @Andrew_Scheps
                                                                            2021-08-19 12:00:00.771Z

                                                                            There isn't a script as such, but all of the building blocks are in the script above. If I get time I'll adapt it to do what you're talking about. Thanks.