No internet connection
  1. Home
  2. Support

Switching App Focus

By Graham Archer @Graham_Archer
    2019-09-18 09:02:10.877Z

    This is something I used to do in Keyboard Maestro all the time and I'd like to know how to do it in SF.
    I get this is how to bring Pro Tools into focus:

    sf.ui.proTools.appActivateMainWindow();

    and I can do the same with Finder:

    sf.ui.finder.appActivateMainWindow();

    But I'd like to do the same with UAD console (or any other app for that matter) but I don't see it in the pre-defined list of commands. In my head it would look like this:

    sf.ui.Console.appActivateMainWindow();

    but that doesn't work. Is it possible to do in SF?

    Thanks in advance!

    Solved in post #2, click to view
    • 6 replies
    1. Hi @Graham_Archer.

      Yes this is possible in SoundFlow.
      The easiest way to get the Javascript code for this would be to use the Macro Editor.

      Your steps:

      • Create a new Macro by pressing "+ New" and choose "Macro".
      • Click the "Add Action" button, search for the "Activate App's Main Window" action and click to add it.
      • In the "Application" property, select the App you want to activate.

      Now you have a macro that does this.
      If you want to convert this action to Javascript, click the three small dots, and choose Copy as Javascript.
      Now you can paste the code into a Script command.

      ReplySolution
      1. GGraham Archer @Graham_Archer
          2019-09-18 09:50:18.006Z

          Hey @chrscheuer thanks so much for this answer. I've tried this as a macro and also as script, it works but SF is flagging an error message and I'm not sure why. I have:

          sf.ui.app('com.uaudio.console').appActivateMainWindow();

          and the error I'm getting is:

          "Script error at line 2
          Could not find Main Window UI for Application with b..."

          I can't see all of the message unfortunately! In fact on the script I'm using, there isn't even a line 2. I'm a bit puzzled as to why it's being flagged - any ideas?

          1. Hi @Graham_Archer.

            Try using the appActivate action instead:

            sf.ui.app('com.uaudio.console').appActivate();
            
            1. GGraham Archer @Graham_Archer
                2019-09-18 09:58:47.614Z

                That works perfectly! Thank you!

          2. J
            In reply toGraham_Archer:
            Jeremiah Moore @Jeremiah_Moore
              2021-11-16 22:26:31.008Z

              Hi all - reviving this with a specific question: Activating an app only seems to work if the app is already launched.

              How do we activate the app including launching it if it's not already launched?

              Basic functionality wanted is: you push the "soundminer" button, you get soundminer, whether it's launched yet or not.

              1. JJeremiah Moore @Jeremiah_Moore
                  2021-11-17 01:43:50.709Z

                  Note to any users seeking similar answer: There is a command called "Launch Application" which acts in the manner desired.