No internet connection
  1. Home
  2. How to

UAD Console: How hard can it be to hide it?

By Eric Huergo @Eric_Huergo
    2021-10-21 10:04:53.580Z2021-10-21 10:16:26.398Z

    Hello everyone, new and excited to be here and this is my first post but essentially I'm trying to make an incredibly simple script to toggle with a streamdeck. I'm trying to get a button to bring up UAD Console when pressed and if UAD Console is already at the front, to proceed to hide it.

    I've managed to get other apps to cooperate flawlessly but it seems that UAD's got something going on in the backend to probably prevent this sort of thing from happening. I'm wondering if anyone's been able to get it to work and if so if they could kindly show me their ways. I've tried everything from following menu items, to mouse clicks to even launching force quit and trying out some stuff there but unfortunately nothing's worked and I'm pretty stumped. My latest attempt looks like this:

    const appName = 'Console*';
    const appRef = sf.ui.app('com.uaudio.ua_mixer_engine');
    const appPath = '/Applications/Universal Audio/Console.app';
    
    const isAppRunning = appRef.isRunning;
    const isAppFrontmost = sf.ui.frontmostApp.uiElement['Title'] === appName;
    const isAppWindowOpen = appRef.windows.length > 0;
    
    switch (true) {
        case (!isAppRunning):
            sf.app.launch({ path: appPath });
            break
        case (!isAppFrontmost && isAppWindowOpen):
            sf.app.launch({ path: appPath });
            break
        case ((!isAppFrontmost || isAppFrontmost) && !isAppWindowOpen):
            sf.app.launch({ path: appPath });
            break
        case (isAppFrontmost && isAppWindowOpen):
            sf.wait();
            
            sf.mouse.click({
            position: {"x":75,"y":10},
            });
    
            sf.wait({
            intervalMs: 500,
            });
    
            sf.mouse.click({
            position: {"x":75,"y":70},
            });
    
    }
    

    Forgive me for what I don't know but thank you for helping.

    Kindest, Eric.

    • 7 replies
    1. In reply toEric_Huergo:
      Chris Shaw @Chris_Shaw2021-10-21 16:51:39.280Z2021-10-21 18:30:01.862Z

      It's tricky because the console app menus are addressed by SF with com.uaudio.console, the app itself is addressed by the OS as "UA Mixer Engine", and the main menu item is called "Console".

      Pretty convoluted and confusing - it took me a bit to figure it out.
      This should do it:

      const appPath = '/Applications/Universal Audio/Console.app';
      const isAppFrontmost = sf.ui.frontmostApp.title.value == "UA Mixer Engine"
      const appRef = sf.ui.app('com.uaudio.console')
      const isAppRunning = appRef.isRunning;
      
      switch (true) {
          case (!isAppRunning):
              sf.interaction.notify({title:"Launching Console"})
              sf.app.launch({ path: appPath });
              break
          case (!isAppFrontmost):
              appRef.appActivate();
              break
          case (isAppFrontmost):
              appRef.menuClick({
                  menuPath: ["Console", "Hide Console"],
              });
      };
      

      I also got rid of some unnecessary switch cases - there's no need to check if the console window exists because it's impossible to have Console running with no window open. All you have to check for is if the app is active and/or frontmost. If it isn't active the script launches it which brings it to the front. If the app isn't frontmost then the script activates the main window. Finally, if the app is frontmost then the script hides it by clicking the Console menu item "Hide Console".

      • I added a "Launching Console" notification because there is a bit of a delay before the Console window appears but you can delete that if you like.
      1. Eric Huergo @Eric_Huergo
          2021-10-21 19:15:00.106Z

          Chris, you legend - thank you so much for that. As you guessed that did it without a problem! Also, appreciate you going the extra step and getting rid of those switch cases / adding that notification - will definitely be changing the ones I got to work to match - that notification is a very nice touch. :)

          Once again, thank you - I really, really appreciate it!!! :)

          1. Chris Shaw @Chris_Shaw2021-10-21 19:31:11.649Z2021-10-22 00:06:55.584Z

            Glad it works.
            I realized that it is possible for the Console app to be open with the mixer window closed and the settings window open. If you always want to insure that the mixer window is open when you switch to Console use this script instead:

            const appPath = '/Applications/Universal Audio/Console.app';
            const isAppFrontmost = sf.ui.frontmostApp.title.value == "UA Mixer Engine"
            const appRef = sf.ui.app('com.uaudio.console')
            const isAppRunning = appRef.isRunning;
            const mixerEngineApp = sf.ui.app("com.uaudio.ua_mixer_engine")
            const isMixerOpen = mixerEngineApp.windows.whoseTitle.startsWith("Console:").first.exists;
            
            switch (true) {
                case (!isAppRunning):
                    sf.interaction.notify({ title: "Launching Console" });
                    sf.app.launch({ path: appPath });
                    break
                case (isAppRunning && !isMixerOpen):
                    mixerEngineApp.getElement("AXExtrasMenuBar").popupMenuSelect({
                        menuPath: ["Console"],
                    });
                    break
                case (!isAppFrontmost && isMixerOpen):
                    appRef.appActivate();
                    break
                case (isAppFrontmost):
                    appRef.menuClick({
                        menuPath: ["Console", "Hide Console"],
                    });
            };
            
            1. Eric Huergo @Eric_Huergo
                2021-10-21 21:09:29.378Z

                Chris, you're a doggone saint. I can't tell you how much I appreciate the help, you've truly gone above and beyond and it really makes a difference.

                Once again, thank you and I can't wait to have invested enough time into Soundflow to be fluid in it so I can share creations with people! Appreciate you! :)

                1. In reply toChris_Shaw:
                  TTorm Utecht @Torm_Utecht
                    2022-09-19 15:39:58.306Z

                    Hey@Chris_Shaw. Hi all!

                    Thanks for doing great work programming that script. Unfortunately, I always end up in the lauch-case. So I figure something is different either between my and the standard mac os, or between 2021 and today?

                    Any other hint?

                    1. Lauch case?
                      Hmm. :)

                      Unfortunately I don't have a UAD interface anymore so I have no way of debugging it.

                      1. TTorm Utecht @Torm_Utecht
                          2022-09-21 10:50:09.139Z

                          Hey! I am sorry for my bad spelling.

                          The case statement from where you launched the application within your script.

                          Best, Torben

                2. Progress
                3. @Eric_Huergo deleted this topic 2021-10-21 10:08:01.287Z.
                4. @Eric_Huergo undeleted this topic 2021-10-21 10:15:23.552Z.