Hi! I'm working on a script that opens the RX7 connect plugin, but I want to make an if statement that skips opening the plugin if it's already open. How do I verify if the window is not open?
would it be:
(sf.ui.proTools.getFloatingWindowWithTitleStartingWith("Audio Suite: RX 7 Connect") == null)
?
Thanks!
Dustin
- Dustin Harris @Dustin_Harris
Found it by creepin' on other plugins!
var panel = sf.ui.proTools.getFloatingWindowWithTitleStartingWith("Audio Suite: RX 7 Connect");
if (panel.exists) throw 'RX7 Connect is already open';Christian Scheuer @chrscheuer2019-10-02 07:15:53.712Z
Great Dustin - thanks for posting the solution :)
Christian Scheuer @chrscheuer2019-10-02 07:18:27.416Z2019-10-02 16:59:19.820Z
You can also do this:
var asWin = sf.ui.proTools.getAudioSuiteWindow("RX 7 Connect"); if (!asWin.exists) { asWin = sf.ui.proTools.audioSuiteOpenPlugin({ category: "Noise Reduction", name: "RX 7 Connect", }).window; } //Now you can use asWin as expected... asWin.audioSuiteSelectPreset({ presetMenuPath: ['.....'] }); asWin.audioSuiteSetOptions({ processingInputMode: 'ClipByClip', processingOutputMode: 'CreateIndividualFiles', }); asWin.audioSuiteRender();
Dustin Harris @Dustin_Harris
Oh that is way more functional! Thanks!!
- In reply tochrscheuer⬆:
Dustin Harris @Dustin_Harris
Ok so interestingly, the above code seems to always return !asWin.exists = true. In my example the last step in opening the plugin is to toggle the target button (to keep the plugin open). When I run the code several times I get several instances of RX7 Connect on top of each other. Maybe I'm doing something wrong though?
sf.ui.proTools.appActivateMainWindow();
var asWin = sf.ui.proTools.getAudioSuiteWindow("Audio Suite: RX 7 Connect");
if (!asWin.exists) {
asWin = sf.ui.proTools.audioSuiteOpenPlugin({
category: "Noise Reduction",
name: "RX 7 Connect",
}).window;
}
//else {}
asWin.audioSuiteSetOptions({
processingInputMode: "ClipByClip",
processingOutputMode: "CreateIndividualFiles",});
asWin.buttons.whoseTitle.is('Target button').first.elementClick();
I tried wrapping the text in a code block, hopefully it works? :)
Christian Scheuer @chrscheuer2019-10-02 16:59:38.686Z
Thanks @Dustin_Harris, that's my bad. There was a mistake in the first line (I've edited the script now)
The first line should be:
var asWin = sf.ui.proTools.getAudioSuiteWindow("RX 7 Connect");
Dustin Harris @Dustin_Harris
I must be doing something wrong, even with the amended command, !asWin.exsists is always true, and new windows always open.
// make pro tools the active window sf.ui.proTools.appActivateMainWindow();
// check if the plugin is already open
var asWin = sf.ui.proTools.getFloatingWindowWithTitleStartingWith("RX 7 Connect");
if (!asWin.exists){
// Verify if IF statement is triggered
log('If Statement triggered');//open plugin as var asWin is not existing var asWin = sf.ui.proTools.audioSuiteOpenPlugin({ category: 'Noise Reduction', name: "RX 7 Connect" }).window; }
//if not, open the plugin and save the plugin window to the "asWin" variable
else{}
asWin.audioSuiteSetOptions({
processingInputMode: "ClipByClip",
processingOutputMode: "CreateIndividualFiles",});
asWin.buttons.whoseTitle.is('Target button').first.elementClick();
`
EDITOF COURSE I figured it out 30sec after I hit send on the last message. replace getFloatinWindow... with getAudioSuiteWindow :)
- ZZach McNees @Zach_McNees
I can't quite seem to get this working with an Auto Align Post macro. It's working great, but it keeps opening a new instance of AAP every time, when I'd prefer it just check if there's one open first. Did anyone successfully get this working? Here's my current code:
// get window
var asWin = sf.ui.proTools.getAudioSuiteWindow("Auto-Align Post");//Open the plugin
asWin = sf.ui.proTools.audioSuiteOpenPlugin({
category: 'Other',
name: "Auto-Align Post"
}).window;//Set processing options
asWin.audioSuiteSetOptions({
processingInputMode: "ClipByClip",
processingOutputMode: "CreateIndividualFiles"
});// // Set Handle length to 4
// asWin.textFields.whoseTitle.is('Processing Handle Length in Seconds').first.elementClick();
// sf.keyboard.type({
// text: "4",
// });
// sf.keyboard.press({
// keys: "return",
// });//Select Key Input
sf.ui.proTools.firstAudioSuiteWindow.popupButtons.whoseTitle.is('Key Input').first.popupMenuSelect({
menuPath: ["1 DIA 1"],
});///Analyze
// asWin.getFirstWithTitle("Analyze").elementClick();///Wait till analyze done
// sf.ui.proTools.waitForNoModals();//Render
asWin.audioSuiteRender();// // Close Window
// sf.ui.proTools.viewCloseFocusedFloatingWindow();Dustin Harris @Dustin_Harris
here's how I'm doing that same thing... adjust the end of it to suit your needs in terms of key input and processing modes :)
let asWin = sf.ui.proTools.getAudioSuiteWindow('Auto-Align Post'); if (!asWin.exists) { function getCategoryName() { let flatCategories = sf.ui.proTools.getMenuItem('AudioSuite').children.first.children.allItems; let categories = flatCategories.map(n => n.title.value); let manufacturerView = categories.includes('Sound Radix'); return (manufacturerView) ? 'Sound Radix' : 'Other'; } asWin = sf.ui.proTools.audioSuiteOpenPlugin({ category: getCategoryName(), name: "Auto-Align Post" }).window; } while (!asWin.exists) sf.wait({ intervalMs: 50 }); asWin.audioSuiteSetOptions({ processingInputMode: "EntireSelection", processingOutputMode: "CreateContinuousFile", });