No internet connection
  1. Home
  2. How to

How to wait for a Pro Tools confirmation dialog and make it accept

By Matteo Lugara @Matteo_Lugara
    2020-10-09 16:13:11.079Z

    I'm trying to create a new script. I have just create a script "Copy clip to next track at the same position. But the two tracks have different send item. And when i run this script, to protools appear this message that stop the script. I don't find the solution to confirm the message. Wait for request. Best Regards.

    Solved in post #2, click to view
    • 5 replies
    1. Hi Matteo,

      Try adding the following script right after you paste the clip into the new track.

      if (sf.ui.proTools.confirmationDialog.exists) {
          sf.ui.proTools.confirmationDialog.elementWaitFor({
              waitType: "Appear",
          }); // The dialog takes a little bit of time to show up, so we wait
      
          sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is('OK').first.elementClick();
      
          sf.ui.proTools.confirmationDialog.elementWaitFor({
              waitType: "Disappear",
          });
      }
      ReplySolution
      1. MMatteo Lugara @Matteo_Lugara
          2020-10-12 10:42:47.678Z

          Great! Thanks!!

        • Linus Gidstedt @Linus_Gidstedt
            2022-11-19 16:43:28.411Z

            I think the wait needs to be put before the if statement. There is no need to wait for the confirmation dialog if it already exists.

            1. @Linus_Gidstedt, that's a good observation. Hopefully, I can bring some clarity.

              โ€œI think the wait needs to be put before the if statement.โ€


              The script was written to handle the possibility of the dialog not showing up. If it doesn't, it will skip right through.

              If you're writing a script in which you know for sure that you'll encounter one, then you can remove the if statement altogether.

              โ€œThere is no need to wait for the confirmation dialog if it already exists.โ€


              I left a comment on the script that hints on what's going on:

              // The dialog takes a little bit of time to show up, so we wait
              

              What's happening here is that the confirmation dialog is registered by SoundFlow as "existing" slightly before it is actually rendered on screen by Pro Tools. SoundFlow moves extremely fast so during testing it managed to squeeze in that elementClick() on the "OK" button before the dialog was rendered, resulting in an error since there wasn't a button to interact with yet.

              Adding that elementWaitFor() at the top of the if statement ensures that the confirmation dialog is rendered before moving forward.

              I can imagine how this wait can be influenced by the system's performance. If a user runs this on a fast machine, the wait might not be necessary at all. In this case, the wait ensures that it will work on any system ๐Ÿ‘๐Ÿผ.

              Hope that makes sense!

              1. Linus Gidstedt @Linus_Gidstedt
                  2022-11-20 20:25:14.563Z

                  It makes sense. It's just that on my system the confirmation dialog is showing up to slow making SoundFlow always skip right through. the solution was to add a wait before your code

                  sf.wait({ intervalMs: 100 });
                  
                  if (sf.ui.proTools.confirmationDialog.exists) {
                      sf.ui.proTools.confirmationDialog.elementWaitFor({
                          waitType: "Appear",
                      }); // The dialog takes a little bit of time to show up, so we wait
                  
                      sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is('OK').first.elementClick();
                  
                      sf.ui.proTools.confirmationDialog.elementWaitFor({
                          waitType: "Disappear",
                      });
                  }
                  

                  But that's just a minor addition. I see now why you have that elementWaitFor() right before elementClick()
                  Thanks for clarifying!