How does one get the name of a plugin that is open or selected?
I've tried (maybe not hard enough) get the name from the open plugin window dropdown (insert position selector) but there no Enabled or isChecked property as far as I can see.
- Kitch Membery @Kitch2020-07-23 00:06:51.944Z2020-07-23 01:10:25.115Z
Chris mate!
This will get you the current insert Title ie. a-j ;
const insertPositionSelectorMenuTitle = sf.ui.proTools.windows.whoseTitle.is('Plug-in: EQ3 1-Band').first.popupButtons.whoseTitle.is('Insert Position selector').first.value.invalidate().value; log(insertPositionSelectorMenuTitle);
This will get you the insert position selector menu items as an array;
const insertPositionSelectorMenuItemsArray =sf.ui.proTools.windows.first.popupButtons.whoseTitle.is('Insert Position selector').first.popupMenuFetchAllItems().menuItems.join(',').split(','); log(insertPositionSelectorMenuItemsArray);
I'll work on comparing the title and the array items later.
That gets you half way there at least (if only they were checked items).
Rock on!
Chris Shaw @Chris_Shaw2020-07-23 01:27:35.867Z
Thanks!
This is what I need for a script I’m working on. Will probably have it up by tomorrow. No need to get me the compare part of the script - I’ve already got that.
And yes, if only they were checked items.Kitch Membery @Kitch2020-07-23 01:28:42.266Z
My pleasure Chris!
- In reply toKitch⬆:
Kitch Membery @Kitch2020-07-23 02:57:45.743Z
Hey Chris,
I figured it would be nice to give the other forum users a complete answer for your question so...
Here it is as a function that returns the plugin name from the "insert position selector" popup button. (I'm sure Christian could do this whole function in one line of code Hahahahhaa).
function insertPositionPluginName() { const btn = sf.ui.proTools.windows.first.popupButtons.whoseTitle.is('Insert Position selector').first; let buttonTitle = btn.value.invalidate().value; let insertPositionSelectorMenuItemsArray = btn.popupMenuFetchAllItems().menuItems.join(',').split(','); let pluginNameFromArray = insertPositionSelectorMenuItemsArray.find(element => element.startsWith('insert ' + buttonTitle + ' ')); let pluginName = pluginNameFromArray.replace('insert ' + buttonTitle + ' (', '').slice(0, -1); return pluginName; } let pluginName = insertPositionPluginName(); log(pluginName);
Kitch Membery @Kitch2020-07-23 03:13:23.057Z
I may have over thought it. You can get the plugin name from the plugin selector dropdown like this;
let pluginName = sf.ui.proTools.windows.first.popupButtons.whoseTitle.startsWith('Plug-In Selector').first.value.invalidate().value; log(pluginName);
Chris Shaw @Chris_Shaw2020-07-23 23:18:21.557Z
I realize that I also need the insert letter as well (see below).
If there are multiple instances of the same plugin then my script won't work without it.Thanks for your patience.
- In reply toChris_Shaw⬆:
Chris Shaw @Chris_Shaw2020-07-23 23:53:24.930Z
It's seems you longer script works for what I'm looking for however there is an error in it. When I run your script on its own it works even with the error but in context of my longer script it crashes. Can you check the syntax? It's with the
.find
in line 7.Thanks again Kitch!
Kitch Membery @Kitch2020-07-24 05:42:47.899Z
Chris Mate!
The red undeline in the editor is superficial as the "find" method is a newer addition to javascript that the SoundFlow editor does not validate the syntax yet. Here is a way to fix that issue by using the "filter" method instead of "find".
function insertPositionPluginName() { //Insert Position selector button const btn = sf.ui.proTools.windows.first.popupButtons.whoseTitle.is('Insert Position selector').first; //Button title ie 'a-j' let buttonTitle = btn.value.invalidate().value; //Menu Item String converted to Array let insertPositionSelectorMenuItems = btn.popupMenuFetchAllItems().menuItems.join(',').split(','); log(typeof(insertPositionSelectorMenuItems)); //Filter Menu Item array to select matched item let pluginNameFromArray = insertPositionSelectorMenuItems.filter(element => element.charAt(7) === buttonTitle); //Modify the filtered item to remove "insert " , "Button title", " (" & ")" let pluginName = String(pluginNameFromArray).replace('insert ' + buttonTitle + ' (', '').slice(0, -1); //Hack to close popup menu (This line may be problematic in your script) sf.ui.proTools.appActivateMainWindow(); return pluginName; } let pluginName = insertPositionPluginName(); log(pluginName);
Unfortunatly I can't make it work more than once without adding the
sf.ui.proTools.appActivateMainWindow();
to close the popup that stays open. Fingeres crossed this doesn't effect your script.Hope that helps.
Rock on!Kitch Membery @Kitch2020-07-24 05:53:32.271Z
If you want to have the plugin position and name returned from the function you can return an object from the funtion like this;
function insertPositionPluginName() { //Insert Position selector button const btn = sf.ui.proTools.windows.first.popupButtons.whoseTitle.is('Insert Position selector').first; //Button title ie 'a-j' let buttonTitle = btn.value.invalidate().value; //Menu Item String converted to Array let insertPositionSelectorMenuItems = btn.popupMenuFetchAllItems().menuItems.join(',').split(','); log(typeof (insertPositionSelectorMenuItems)); //Filter Menu Item array to select matched item let pluginNameFromArray = insertPositionSelectorMenuItems.filter(element => element.charAt(7) === buttonTitle); //Modify the filtered item to remove "insert " , "Button title", " (" & ")" let pluginName = String(pluginNameFromArray).replace('insert ' + buttonTitle + ' (', '').slice(0, -1); //Hack to close popup menu sf.ui.proTools.appActivateMainWindow(); return { name: pluginName, position: buttonTitle, } } let plugin = insertPositionPluginName(); log(`${plugin.position} ${plugin.name}`);
- In reply toKitch⬆:
Chris Shaw @Chris_Shaw2020-07-23 19:19:59.206Z
Actually, you need to mod your line for getting the insert title (it's looking for the EQ plugin):
const insertPositionSelectorMenuTitle = sf.ui.proTools.windows.whoseTitle.is('Plug-in: EQ3 1-Band').first.popupButtons.whoseTitle.is('Insert Position selector').first.value.invalidate().value;
For any plugin this works:
const insertPositionSelectorMenuTitle = sf.ui.proTools.windows.whoseTitle.whoseTitle.startsWith('Plug-In Selector').first.popupButtons.whoseTitle.is('Insert Position selector').first.value.invalidate().value;
Kitch Membery @Kitch2020-07-23 19:26:12.201Z
Silly mistake, I forgot to change that in the UI picker. Did you see my more recent posts on this?
Chris Shaw @Chris_Shaw2020-07-23 20:14:41.476Z
Yes. Very helpful. Thanks
I'm almost done with the script I'm using this for. As always, error and condition checking is always the part that takes ages…Kitch Membery @Kitch2020-07-23 20:15:46.185Z
Excellent. I look forward to trying it out!
- In reply toChris_Shaw⬆:Chris Shaw @Chris_Shaw2020-07-24 17:52:31.808Z2020-07-26 00:00:49.753Z
Here is the completed script. Thanks so much for your help (truly).
It cycles/steps through all the active inserts on a track while skipping inactive plugins or unassigned inserts.
I modified your script slightly to pass the active insert name and a flat insert array into the plugin object. I didn't need the button on it's own.sf.ui.proTools.appActivate(); const sup = sf.ui.proTools sup.invalidate(); sup.appActivateMainWindow(); try { sup.floatingWindows.whoseTitle.contains('Plug-in:').first.elementRaise(); function insertPositionPluginName() { //Insert Position selector button const btn = sf.ui.proTools.windows.first.popupButtons.whoseTitle.is('Insert Position selector').first; //Button title ie 'a-j' let buttonTitle = btn.value.invalidate().value; //Menu Item String converted to Array let insertPositionSelectorMenuItems = btn.popupMenuFetchAllItems().menuItems.join(',').split(','); //Filter Menu Item array to select matched item let pluginNameFromArray = insertPositionSelectorMenuItems.filter(element => element.charAt(7) === buttonTitle); //Hack to close popup menu sf.ui.proTools.appActivateMainWindow(); return { name: pluginNameFromArray, flatPluginlistMenuList: insertPositionSelectorMenuItems, } } //Get active plugin name and Insert selector list let plugin = insertPositionPluginName(); const activePluginName = plugin.name.toString(); const flatPluginlistMenuList = plugin.flatPluginlistMenuList; // Sort Flat plugin Menu List to show only inserts with plugins let sortedPlugins = flatPluginlistMenuList.filter(function (item) { let checkSlot = item.indexOf("("); return checkSlot == 9 }); sup.appActivateMainWindow(); // determine index of current plugin let activePlugsIndex = sortedPlugins.length; for (var i = 0; i != activePlugsIndex; i++) { if (sortedPlugins[i].indexOf(activePluginName) != -1) { break; } } // open next plugin let nextPlugIndex = i + 1; if (nextPlugIndex == activePlugsIndex) { nextPlugIndex = 0; } sup.windows.whoseTitle.contains('Plug-in:').first.popupButtons.whoseTitle.is('Insert Position selector').first.popupMenuSelect({ menuPath: [sortedPlugins[nextPlugIndex]], }); // routine for no open plugin wincow or inactive window if ((sup.focusedWindow.title.value) == "") { while ((sup.focusedWindow.title.value) == "") { nextPlugIndex = nextPlugIndex + 1; if (nextPlugIndex == activePlugsIndex) { nextPlugIndex = 0; } sup.windows.whoseTitle.is('').first.popupButtons.whoseTitle.is('Insert Position selector').first.popupMenuSelect({ menuPath: [sortedPlugins[nextPlugIndex]], }); } } } catch (err) { log("Please open / select an active plugin window…", ""); throw 0 }
Kitch Membery @Kitch2020-07-24 19:11:10.226Z
Nice work Chris!