Hi!
Would it be possible for a streamdeck button to toggle?
What I want to do is having one button opening an audiosuite plugin.
And when I press the same button again the plugin closes.
- Christian Scheuer @chrscheuer2019-09-19 22:55:44.805Z
First check out this discussion:
https://forum.soundflow.org/-1001/can-sf3-toggle-2-macros-on-the-same-sd-keyIn this post I show a script that toggles between two commands
https://forum.soundflow.org/-1001#post-11However, the best way to do it is to do the action based on what the actual state in Pro Tools is. Meaning, if the window is open, close it, if it wasn't open, open it. You can't do that with a generic toggle-script (it would just toggle based on the number of times you had clicked it, regardless of the state inside PT), you need a specialized script for that. So let's build the special script for toggling audio suite windows.
var pluginCategory = 'EQ'; var pluginName = 'EQ3 7-Band'; var win = sf.ui.proTools.getAudioSuiteWindow(pluginName); if (win && win.exists) { win.windowClose(); } else { sf.ui.proTools.audioSuiteOpenPlugin({ name: pluginName, category: pluginCategory }); }
- JJens Johansson @Jens_Johansson
Sweet... works exactly as I want to :) This will be my new default script for use with AudioSuite and Stremdeck.
Thanks Christian for your quick reply and coding skills.
- In reply tochrscheuer⬆:JJonathan Grossman @Jonathan_Grossman
I'm trying to apply this to toggle between outputs on my MAC. What am I doing wrong?
//This reverses the value of globalState.myVariable outputState.var = !outputState.var; var volumeMenu = sf.ui.app('com.apple.systemuiserver').getElement("AXMenuBar").children.whoseDescription.startsWith('volume ').first; volumeMenu.popupMenuSelect({ if (outputState.var) { menuPath: ['Duet USB'] } else { menuPath: ['Source-Nexus'] }
Christian Scheuer @chrscheuer2020-06-11 22:09:22.854Z
You were close in some ways, but I took the liberty of making this a fully customizable function where you can have as many devices to switch between as you wish:
const itemsToSwitch = ['Duet USB', 'Source-Nexus']; var volumeMenu = sf.ui.app('com.apple.systemuiserver').getElement("AXMenuBar").children.whoseDescription.startsWith('volume ').first; volumeMenu.popupMenuSelect({ menuSelector: menuItems => { const candidates = menuItems.filter(mi => itemsToSwitch.indexOf(mi.names[0]) >= 0); const selectedItem = candidates.map((menuItem, index) => ({ menuItem, index })).filter(m => m.menuItem.element.isMenuChecked)[0]; const oldIndex = selectedItem ? selectedItem.index : -1; let newIndex = oldIndex + 1; if (newIndex >= candidates.length) newIndex = 0; return candidates[newIndex]; }, });
- JJonathan Grossman @Jonathan_Grossman
Whammo! Thank you.