No internet connection
  1. Home
  2. How to

How do I get two codes (macro) to run alternately (with one macro)

By Min Kyu Kang @Min_Kyu_Kang
    2024-08-14 05:12:59.525Z

    How do I get two codes (macro) to run alternately (with one macro)

    Solved in post #6, click to view
    • 7 replies
    1. Kitch Membery @Kitch2024-08-14 18:00:52.297Z

      Hi @Min_Kyu_Kang,

      Thanks for asking.

      To be able to provide the best solution, can you provide more information on what you are trying to achieve and the manual steps that you'd take to achieve the desired outcome?

      1. MMin Kyu Kang @Min_Kyu_Kang
          2024-08-15 01:58:18.457Z

          I made two codes to adjust the output gain of the RX Editor to 0 or +6.

          (Each works well)(And I made this code because when I work with Pro Tools, there is a plug-in that raises the volume in the plug-in with insert, so when I send it to RX, the volume is too small and the monitor is hard.)

          I just want to put this in one stream deck button, but it's not working.

          I think it would be good to put two in one button and execute the code alternately.

          1. Kitch Membery @Kitch2024-08-15 02:34:14.499Z

            Hi @Min_Kyu_Kang,

            Thanks for providing more context.

            Do you want to be able to toggle between output gain of 0 and +6? and in what RX module are you trying to do this?

            Also, so that I have a starting point, can you provide the scripts you have so far, for the two functions?

            Thanks in advance.

            1. MMin Kyu Kang @Min_Kyu_Kang
                2024-08-15 02:39:35.394Z
                sf.keyboard.press({
                    keys: "cmd+comma",
                });
                
                sf.mouse.click({
                    position: {"x":1150,"y":723},
                });
                
                sf.keyboard.type({
                    text: "0",
                });
                
                sf.keyboard.press({
                    keys: "return",
                });
                
                sf.keyboard.press({
                    keys: "return",
                });
                
                

                is very simple code (just 0 or 6 change), it works for me perfectly.

                it change RX output volume, not RX module.

                1. Kitch Membery @Kitch2024-08-15 03:16:11.176Z

                  Thanks for providing the script @Min_Kyu_Kang,

                  I see from the code that you're using mouse and keyboard simulation which is the least stable way to control an app with SoundFlow. It's always best to use UI automation wherever possible.

                  With that said this one required some more complex logic to get it working but Here is a script that should do what you're after.

                  function toggleRxOutputGain() {
                      // Activate iZotope RX's main window
                      sf.ui.izotope.appActivateMainWindow();
                  
                      const iZotopeMenuName = sf.ui.izotope.childrenByRole("AXMenuBar").first.children.find(mi => {
                          return mi.title.invalidate().value.startsWith("iZotope RX")
                      }).title.invalidate().value;
                  
                      // Open Preferences Window
                      sf.ui.izotope.menuClick({ menuPath: [iZotopeMenuName, "Preferences…"], });
                  
                      const preferencesWindow = sf.ui.izotope.windows.find(win =>
                          win.childrenByFullRole("AXWindow:AXDialog") &&
                          win.title.invalidate().value === "Preferences"
                      );
                  
                      // Wait for Preferences window
                      preferencesWindow.elementWaitFor();
                  
                      // Get the Output Gain slider
                      const outputGainSlider = preferencesWindow.getFirstWithDescription("Output gain [dB]");
                  
                      // Get the current gain value
                      const currentGain = outputGainSlider.value.doubleValue;
                  
                      // Function to set the Output Gain slider
                      const setOutputGain = (gain) => outputGainSlider.value.value = String(gain);
                  
                      // If the Output Gain is set to 0.0 set it to 6.0, if it is not, set it to 0.0 
                      if (currentGain === 0) {
                          setOutputGain(6.0)
                      } else {
                          setOutputGain(0.0)
                      }
                  
                      // preferencesWindow.windowClose(); Remove the "//" at the start of this line if you want the preferences window to close.
                  }
                  
                  toggleRxOutputGain();
                  

                  I hope that helps. :-)

                  Reply1 LikeSolution
                  1. MMin Kyu Kang @Min_Kyu_Kang
                      2024-08-15 03:23:10.549Z

                      Awsome, it works perfectly. Thanks!

                      1. Kitch Membery @Kitch2024-08-15 03:28:46.841Z

                        You’re welcome. :-)