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.
Linked from:
- Raphael Sepulveda @raphaelsepulveda2020-10-09 19:32:46.125Z
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", }); }
- MMatteo Lugara @Matteo_Lugara
Great! Thanks!!
- In reply toMatteo_Lugaraโฌ:Linus Gidstedt @Linus_Gidstedt
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.
Raphael Sepulveda @raphaelsepulveda2022-11-20 03:46:44.157Z
@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 theif
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!
Linus Gidstedt @Linus_Gidstedt
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 beforeelementClick()
Thanks for clarifying!