No internet connection
  1. Home
  2. Macro and Script Help

Click UI Element with modifier key and without being tied to a specific App

Title

Click UI Element with modifier key and without being tied to a specific App

What do you expect to happen when you run the script/macro?

I'd like to move the focused application to another screen and then maximize it to that screen0s size.

The moving is easy via "Click Menu Item", but I'm struggling with the maximizing part.

The most elegant option would be to Option + Click the little maximize button on the top left of any given App. Option turns it into a "+" sign, so it won't fullscreen, but maximize the program.

How can I make it click this UI element without it being tied to a specific App? And how can I add the "Hold down Option key while Clicking"?

Thanks :)

Are you seeing an error?

What happens when you run this script?

As mentioned, I can't figure out how to Click the little UI button with both the Option modifier and it being App-agnostic.

How were you running this script?

I clicked the "Run Script" or "Run Macro" button in SoundFlow

How important is this issue to you?

2

Details

{
    "inputExpected": "I'd like to move the focused application to another screen and then maximize it to that screen0s size.\n\nThe moving is easy via \"Click Menu Item\", but I'm struggling with the maximizing part.\n\nThe most elegant option would be to Option + Click the little maximize button on the top left of any given App. Option turns it into a \"+\" sign, so it won't fullscreen, but maximize the program.\n\nHow can I make it click this UI element without it being tied to a specific App? And how can I add the \"Hold down Option key while Clicking\"?\n\nThanks :)",
    "inputIsError": false,
    "inputWhatHappens": "As mentioned, I can't figure out how to Click the little UI button with both the Option modifier and it being App-agnostic.",
    "inputHowRun": {
        "key": "-MpfwYA4I6GGlXgvp5j1",
        "title": "I clicked the \"Run Script\" or \"Run Macro\" button in SoundFlow"
    },
    "inputImportance": 2,
    "inputTitle": "Click UI Element with modifier key and without being tied to a specific App"
}

Source

//Macro converted to script


sf.ui.frontmostApp.menuClick({
    menuPath: ["Window","Move to PA34V"],
});



Links

User UID: ZU2D3n8zVfeIaxCntwFXaCpE7ah1

Feedback Key: sffeedback:ZU2D3n8zVfeIaxCntwFXaCpE7ah1:-Mzo85ibICsK4FmgDRPO

Feedback ZIP

  • 5 replies
  1. Hey @Roger_Baltensperger1, that action is called "Zoom" under the Windows menu so technically you'd only need to do another macro as you did with the "Move to PA34V", but this time with "Zoom". In script form it'd look like this:

    sf.ui.frontmostApp.menuClick({
        menuPath: ["Window", "Zoom"],
    });
    
    1. Hi Raphael

      Thanks for your answer. Yes, I can see "Zoom" in some Apps, but not all of them.

      For example the main Soundflow window does not have it..

      If I however Option + Click the small green "fullscreen" button, it will zoom/maximize the window, instead of it going fullscreen.

      Would I be able to automate this? This would be the preferred way, since these buttons seem to exist, even when "Window -> Zoom" does not.

      Thanks :)

      1. Sure can, here you go:

        sf.ui.frontmostApp.mainWindow.getElement("AXFullScreenButton").elementClick({
            actionName: "AXZoomWindow",
            asyncSwallow: true,
        });
        
        1. Awesome, thank you :)

          So am I correct in assuming that this would be a copy of "Click UI Element", but for the focused instead of a specific application?

          Is there a reason why there is no "frontmostApp" in the existing "Click UI Element" command?

          1. Correct, this is the equivalent of using the Click UI Element macro action, selecting the Maximize button of a window with the UI Element Picker, and setting the action name to "AXZoomWindow", which is the macOS name of the "Zoom" action. This method is more robust than a regular option+click since it's accessing the macOS "Zoom" action directly instead of simulating a click. The main difference here is that a regular option+click would not work as expected if, for example, there is something covering up the maximize button.

            You're right, currently, there isn't a way to configure the macro action to perform on whichever app is frontmost. If you could, post about this in the Ideas section and reference this thread, that way it can be considered for future updates! Tag me and I can provide more technical details.