No internet connection
  1. Home
  2. Support

Streamdeck toggle buttons

By Jens Johansson @Jens_Johansson
    2019-09-19 07:32:47.497Z

    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.

    Solved in post #2, click to view
    • 5 replies
    1. Hi @Jens_Johansson

      First check out this discussion:
      https://forum.soundflow.org/-1001/can-sf3-toggle-2-macros-on-the-same-sd-key

      In this post I show a script that toggles between two commands
      https://forum.soundflow.org/-1001#post-11

      However, 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 });
      }
      
      Reply1 LikeSolution
      1. JJens Johansson @Jens_Johansson
          2019-09-20 08:44:55.877Z

          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.

          1. In reply tochrscheuer:
            JJonathan Grossman @Jonathan_Grossman
              2020-06-11 18:26:11.705Z2020-06-11 22:04:50.875Z

              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']
              }
              
              1. 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];
                    },
                });
                
                1. Whammo! Thank you.