No internet connection
  1. Home
  2. How to
  3. Logic Pro

Element click in Main Window - Logic Pro

By Nicolas Aparicio @Nicolas_Aparicio
    2024-07-26 00:24:26.743Z

    Hi team,

    just wondering if by any chance someone's figured out a way to element click say the Mute button of a track that's out of view in Logic's Main Window/Arrange Window?.
    I know this can be done in the Mixer Window so wondering if there is a way?

    Not sure if the API will let you @Kitch?

    Cheers,
    Nic.

    • 8 replies
    1. Kitch Membery @Kitch2024-07-26 01:27:14.840Z

      Hi @Nicolas_Aparicio,

      With tests that I've done on this, it does not look promising, but I'll add this to the list of things to do a deep dive on.

      For the Tracks Area in the arrange window, clicking the mute button on a track...

      • using the elementClick() method does not work.
      • using the checkboxSet({targetValue:"Toggle"}) method does not work.
      • Using the mouseClickElement() works but requires the element to be visible and not covered by any other elements.

      Something to note... When a track's mute state is active in the Tracks Area, the description of the AXLayoutItem gets ", mute" appended to the name. See below.

      Selecting Mute in the Mixer View also has issues... Using elementClick() works when the UI element is off-screen but mutes all the tracks not just the targeted one, like when you manually Command + Click the mute button.

      1. NNicolas Aparicio @Nicolas_Aparicio
          2024-07-26 02:24:00.881Z

          HI @Kitch,

          Yep, I've seen this happen a few times, it also clicks/changes the Pan knob value for some reason sometimes.
          Thanks for the info Kitch, I'll stick to mouse clicking elements while in view for now.

          Thanks for this btw, will come in handy for a few codes.

          Cheers.

          1. TThomas Linder @Thomas_Linder
              2024-07-29 20:53:17.821Z

              Just a thought experiment here: what about a workaround that involves momentarily opening the Tracks window to the selected Track, then mutes the track, closes Tracks window, and returns to Mixer view? Not very elegant, but gets the job done? Might be better than manually mouse clicking elements?

              1. Kitch Membery @Kitch2024-07-29 21:04:13.844Z

                Hi @Thomas_Linder,

                When you say "Track window" do you mean the "Tracks Area" in the arrange window?

                I love the way you're thinking, but unfortunately, as I mentioned in my last message, there are issues clicking Mute buttons in both the Tracks Area and the Mixer (docked and floating) at the moment.

                Love the suggestions though, teamwork makes the dream work!

                1. TThomas Linder @Thomas_Linder
                    2024-07-29 21:19:34.151Z

                    I apologize, re-reading your original I mistook what DOES work, and made my response inaccurate.

                    You mentioned that mute works in the Mixer window but only when it is foremost. So, essentially, I guess I'm saying, if you have a track selection elsewhere, say while working in the Arrange window, either select the Track you wish to mute manually (which also selects in Mixer) if not programmatically (a bit fancier, asking Logic to return a value to your script); call the Mixer window to be frontmost; have SF execute the mute function that works in Mixer (that you either selected manually, or programmatically, earlier, in Arrange view); and then return you to where you initiated the macro, presumably the Arrange window?

                    It's certainly a fudge, but it might be worthwhile depending how often you have to reach for the mouse?

                    1. Kitch Membery @Kitch2024-07-29 21:24:13.989Z

                      Absolutely. Yeah, I get ya now. That would work.

                      I'll dig a little deeper tonight and see if I can find a better way. Without the need to use mouse simulation or window switching. :-)

                      1. In reply toThomas_Linder:
                        NNicolas Aparicio @Nicolas_Aparicio
                          2024-07-29 23:31:42.677Z

                          Try this Thomas, I had this code done a while ago but didn't link the mixer to follow the Arrange Window 🤦‍♂️ so, it wasn't working properly for me.
                          This should either bring up the mixer in whatever window you are or jump to the Mixer Window if open in the background (which worked great for me, just have it open behind your main window and save the screenset).
                          Don't have Logic with me atm to test it but let me know if it works.
                          @Kitch will probably come up with an updated, more robust version of your idea but hopefully this will work for the moment.

                          function muteSoloTrack(option) {
                          
                              sf.ui.logic.invalidate();
                              sf.ui.logic.appActivate();
                          
                              const trackName = sf.ui.logic.selectedTrackNames[0]
                          
                              // Find Active Window //
                              const activeWindow = sf.ui.logic.mainWindow.title.value
                          
                              const mixerWindow = sf.ui.logic.windows.whoseTitle.contains(" - Mixer").first
                              const mixerPath = mixerWindow.title.value
                          
                              // Go To Mixer Window //
                              if (mixerWindow.exists) {
                                  sf.ui.logic.getMenuItem('Window', mixerPath).elementClick();
                          
                                  const mixerArea = sf.ui.logic.windows.first.groups.whoseDescription.is("Mixer").first.children.whoseRole.is("AXLayoutArea").whoseDescription.is("Mixer").first
                                  const mixerTrackHeaders = mixerArea.children.whoseRole.is("AXLayoutItem").whoseDescription.contains(trackName).first
                          
                                  mixerTrackHeaders.buttons.whoseDescription.is(option).first.elementClick();
                          
                                  // Return To Active Window //
                                  sf.ui.logic.getMenuItem('Window', activeWindow).elementClick();
                          
                              } else {
                                  // Open Mixer Tab //
                                  sf.ui.logic.getMenuItem('Window', 'Open Mixer').elementClick();
                          
                                  const mixerArea = sf.ui.logic.windows.first.groups.whoseDescription.is("Mixer").first.children.whoseRole.is("AXLayoutArea").whoseDescription.is("Mixer").first
                                  const mixerTrackHeaders = mixerArea.children.whoseRole.is("AXLayoutItem").whoseDescription.contains(trackName).first
                          
                                  mixerTrackHeaders.buttons.whoseDescription.is(option).first.elementClick();
                          
                                  sf.ui.logic.getMenuItem('Window', 'Close Mixer').elementClick();
                              };
                          
                          };
                          

                          Call it like this:

                          muteSoloTrack("mute")
                          or
                          muteSoloTrack("solo")
                          
                          1. TThomas Linder @Thomas_Linder
                              2024-07-30 01:27:15.559Z

                              Thanks, Nicolas! I'm just getting started with SF myself, but that certainly looks like something useful once I get that to that kind of functionality. For the moment, my first "get the feet wet" forays with SF will be in setting up decks for my 3rd party plugins and instruments. Not hard to do, and will get me used to working with SF. After that, I'll be looking to expand my horizons with the kinds of things we're talking about here. But thanks again! Wonderful feedback from you guys!