Wait for Button press
Hello there!
I was wondering if there was a way to add a wait, but it would wait until you clicked on a specific button.
FOR EXAMPLE: I am working on a script to find missing files from an imported AAF. I have everything set to find and match the files. I would the script to PAUSE until i have clicked on the COMMIT button. This way, i can assue all my missing files have found a link.
Thank you so much for the help!
Here is the script i have at the moment if you need it. Also open to anything i can do better with this script as well.
sf.ui.proTools.appActivate();
sf.ui.proTools.windows.whoseTitle.is('Missing Files').first.elementWaitFor();
sf.ui.proTools.windows.whoseTitle.is('Missing Files').first.radioButtons.whoseTitle.is('Manually Find & Relink').first.elementClick();
sf.wait({
intervalMs: 200,
});
sf.ui.proTools.windows.whoseTitle.is('Missing Files').first.buttons.whoseTitle.is('OK').first.elementClick();
sf.ui.proTools.windows.whoseTitle.is('Missing Files').first.elementWaitFor({
waitType: "Disappear",
});
sf.ui.proTools.windows.whoseTitle.is('Relink').first.elementWaitFor();
sf.ui.proTools.windows.whoseTitle.is('Relink').first.mouseClickElement({
relativePosition: {"x":70,"y":38},
});
sf.wait({
intervalMs: 200,
});
sf.mouse.click({
position: {"x":107,"y":207},
});
/* sf.wait({
intervalMs: 200,
}); */
/* sf.ui.proTools.windows.whoseTitle.is('Relink').first.tables.whoseTitle.is('TextGridView').allItems[4].elementClick(); */
/* sf.wait({
intervalMs: 200,
}); */
/* sf.keyboard.press({
keys: "cmd+a",
}); */
sf.wait({
intervalMs: 500,
});
sf.mouse.click({
position: {"x":223,"y":66},
});
sf.ui.proTools.windows.whoseTitle.is('Linking Options').first.elementWaitFor({
waitType: "Appear",
});
sf.ui.proTools.windows.whoseTitle.is('Linking Options').first.radioButtons.whoseTitle.is('Find By Name').first.elementClick();
sf.ui.proTools.windows.whoseTitle.is('Linking Options').first.checkBoxes.whoseTitle.is('Match Format').first.elementClick();
sf.ui.proTools.windows.whoseTitle.is('Linking Options').first.checkBoxes.whoseTitle.is('Match Duration').first.elementClick();
sf.wait({
intervalMs: 200,
});
sf.keyboard.press({
keys: "return",
});
sf.wait({
intervalMs: 200,
});
sf.keyboard.press({
keys: "return",
});
sf.wait({
intervalMs: 5000,
});
sf.mouse.click({
position: {"x":311,"y":66},
});
sf.wait({
intervalMs: 200,
});
sf.keyboard.press({
keys: "return",
});
sf.wait({
intervalMs: 200,
});
sf.keyboard.press({
keys: "cmd+w",
});
sf.keyboard.press({
keys: "alt+quote",
});
- Christian Scheuer @chrscheuer2020-11-10 10:11:27.457Z
Hi Mike,
Unfortunately, I don't think there's an easy, positive answer to this question.
While SoundFlow is really good at controlling Pro Tools, it is much, much worse at receiving events from Pro Tools. In fact, we almost entirely don't. What we do is poll the UI for updates, as in every X milliseconds, we check what has changed.
In your case, that means, we would be able to set up something to poll for when the window was closed. Your script could then continue to do what it wants. That works well if you clicked OK, or wanted to continue. But what if you/the user cancelled? The script wouldn't know this. It would just know that the window disappeared.
Since we don't receive the event from Pro Tools, we're flying blind in those situations.One way of dealing with this would be to have your script, instead of just waiting, then put up a confirmation dialog box. In that, just say - "Please verify the settings, and click OK when you're ready".
This would allow you to make any changes in Pro Tools and not have to worry about the script, in the case where you want to cancel.Mike Wax @mikewax
Hey Christian,
Thank you so much for the reply.
While the prompt is up, am i still able to interact with Pro Tools? For example, if one file needed to be relinked, i could just relink it while the prompt is up, than click OK to carry out the script? Or would i need to cancel and re-run the command?
SoundFlow is able to recognize or gather the button info to click on it when using Click UI Element. Is it possible to utilize that protocol in a wait command as well?
Thank you as always for the help!
Chris Shaw @Chris_Shaw2020-11-10 19:07:48.315Z
Yes, you can still interact with PT while a SF prompt is up. It will float above everything I believe.
Christian Scheuer @chrscheuer2020-11-10 19:27:05.924Z
Yes, exactly as @Chris_Shaw said.
The code you'd run would be very simple at that point:
if (!confirm(`Please verify everything is linked correctly, then click OK.`)) throw 0;
The
throw 0
is just a way to cancel out of the script, in case you click Cancel in the popup.Mike Wax @mikewax
Is that essentially that same as doing this?
var verify = prompt("Please verify everything is linked correctly, then click OK"); if (verify == null) { alert("Your process has been cancelled!"); sf.soundflow.stopAll(); }
Christian Scheuer @chrscheuer2020-11-10 19:31:28.776Z
No, they're quite different.
prompt
is for getting text input. In this case, you don't want the user to type in text, you just want confirmation, ie. the user clicking OK or Cancel, so useconfirm
as I showed.Never run
sf.soundflow.stopAll
. It breaks all other scripts. I can't think of any time that it would be a good idea to run that command.
To cancel out of your script, usethrow 0
as suggested.Christian Scheuer @chrscheuer2020-11-10 19:32:24.109Z
Another point is - users tend to understand that clicking Cancel means to cancel. I've had this discussion on UX a couple of times with other people in the past. Generally, I'd highly recommend to not show a notification that something was cancelled by the user. They just clicked Cancel, so that was their intention.
Mike Wax @mikewax
Ok, cool. Very good information to know.
This works beautifully! Thank you for all the information!
Christian Scheuer @chrscheuer2020-11-10 20:42:10.687Z
Awesome! Happy to help :)