No internet connection
  1. Home
  2. How to

Delete Selected Track doesn't always work

By Bergatron Music @Bergatron_Music
    2022-06-22 22:08:21.709Z

    Hey Guys.

    Is there a way I can make my "Delete Selected Track" macro work in Pro Tools no matter what type of track or tracks are selected? I've noticed that if you've selected an Audio Track the "delete" in the track menu says "Delete..." whereas any other tracktype or group of tracks says "Delete" with no dots at the end. Is there a smart way around this so I can have one "Delete Selected Tracks" macro? Thanks in advance!

    • 6 replies
    1. samuel henriques @samuel_henriques
        2022-06-22 22:36:47.017Z

        Hello Bergatron,

        This should do it,

        sf.ui.proTools.appActivateMainWindow();
        
        if (sf.ui.proTools.getMenuItem('Track', 'Delete...').exists) {
            sf.ui.proTools.getMenuItem('Track', 'Delete...').elementClick();
            sf.ui.proTools.confirmationDialog.invalidate().elementWaitFor();
            sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is('Delete').first.elementClick();
        } else if (sf.ui.proTools.getMenuItem('Track', 'Delete').exists) {
            sf.ui.proTools.getMenuItem('Track', 'Delete').elementClick();
        }
        
        1. Bergatron Music @Bergatron_Music
            2022-07-07 17:54:12.843Z

            Thank you.

          • In reply toBergatron_Music:
            Ryan DeRemer @Ryan_DeRemer
              2022-07-06 06:19:29.613Z

              sf.ui.proTools.trackDelete(); will also accomplish this, minus clicking through the confirmation. The code below achieves the same thing a slightly different way. I've found this way of dismissing the confirmation to be a bit quicker and more stable:

              sf.ui.proTools.appActivateMainWindow();
              
              sf.ui.proTools.menuClick({ menuPath: ['Track', 'Delete'], looseMatch: true });
              
              sf.ui.proTools.confirmationDialog.elementWaitFor({ timeout: 300, pollingInterval: 10, onError: 'Continue' });
              if (sf.ui.proTools.confirmationDialog.exists) {
                  sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is('Delete').first.elementClick();
                  sf.ui.proTools.confirmationDialog.elementWaitFor({ waitType: 'Disappear' });
              }
              
              1. Bergatron Music @Bergatron_Music
                  2022-07-07 17:52:51.231Z

                  Thank you.

                • In reply toBergatron_Music:

                  Here's another approach which asks for confirmation before deleting:

                  sf.interaction.displayDialog({
                      title: "!!!! D e l e t e  T r a c k s !!!!",
                      prompt: "Delete Selected Tracks? \n\n (THIS CAN'T BE UNDONE!!)",
                      buttons: ["Cancel", "OK"],
                      defaultButton: "OK",
                      onCancel: "Abort"
                  })
                  
                  sf.ui.proTools.trackDelete();
                  
                  1. Bergatron Music @Bergatron_Music
                      2022-07-07 17:53:23.824Z

                      Thank you!