Minipulate "hidden" menus and windows

Hi,
disclaimer: I’m pretty stupid regarding coding and scripting..

I got great help here some time ago with my Dropbox sync. Some scripting advice. I saw that the script was manipulating some menus in Dropbox that are not visible in the Dropbox app.
This was the script:

tell application "System Events"
tell application process "Dropbox"
tell menu bar 2
tell menu bar item 1
tell menu 1
if exists of menu item "Pause Syncing" then
tell menu item "Pause Syncing"
perform action "AXPress"
end tell
end if
end tell
end tell
end tell
end tell
end tell

These menus are not visible in the app, so how do you find them?
I would like to know a bit more about this because I have some things I want to accomplish in Ableton Live.

When you open a plugin in Ableton Live it has no shortcut to close the plugin floating window again (only hide).. I know this can be done as there are a few apps that are made just to close plugin windows in Ableton with a key command.. I would rather make it myself in KM than having to use a 3. Party app just to do one keystroke-macro..

One app is called Plugin closer and is free

I would also like to know more about navigating inside an app.. Hard to explain, but right-Click menus and sub windows in an app (Ableton Live for now) There is a lot I would like to make shortcuts for and the only way I can figure out myself now is by using “find image” and control the mouse etc. and that is giving me a lot of problems with reliability.

If someone here can point me in the right direction or is willing to help me out (I’m able to pay some money for the work) I would greatly appreciate it!

Thanks

I’m not familiar with Abelton Live, but the script you included in your post is an example of GUI AppleScript, and is reliable as long as the app developers don’t change the accessibility features or app interface too much.

Side note: when posting scripts, enclose the entire thing in three backticks (the character to the left of the 1 key: `), beginning and end, and it will preserve the formatting. For instance, your script would look like this:

tell application "System Events"
	tell application process "Dropbox"
		tell menu bar 2
			tell menu bar item 1
				tell menu 1
					if exists of menu item "Pause Syncing" then
						tell menu item "Pause Syncing"
							perform action "AXPress"
						end tell
					end if
				end tell
			end tell
		end tell
	end tell
end tell

All that being said, take a look at Script Debugger, as it far superior to Apple’s own Script Editor app. You can look through Ableton’s AppleScript dictionary to see if there are any built-in ways to do what you need. If not, then the aforementioned GUI scripting is the only way to do it.

For instance, to simulate clicking the close button, the following works (using Finder as an example):

tell application "System Events"
	tell application process "Finder"
		click button 1 of window 1
	end tell
end tell

You might be able to do the same with Ableton’s plugin windows, however, the window 1 portion would need to be changed to point to whatever window index the plugin has. If you need to get information on all front application windows, look at the Front Window Analysis Tool that @ccstone wrote sometime back that I (and many others) use quite extensively.

Alternatively, if the plugin windows each have a specific, and unchanging name, you can do something like the following:

tell application "System Events"
	tell application process "Finder"
		click button 1 of window "Downloads"
	end tell
end tell

That will ensure the right window closes, irregardless of it’s window index, but again, it has to have a name, and one that does not change.

1 Like

Thanks I really appreciate your help!
I tried the FWA tool to test if I could make a selection in a right click menu.. Im obviously not gifted enough to do it yet :wink:
This is what I get from the tool:

application Process "Live"
window
group 1
group "Context"

menu item "1/16"
menu item "1/32"
menu item "Off"
menu item "Narrow Grid, ⌘1"

I have removed some of it so Its not filling the screen.. I want to make sure menu item “1/16” is selected (if not selected) and I tried to do it with a menu command in KM but no luck. I tried to access the menu by menu:Context and menu item 1/16.. also tried to make a mouse right click before the menu command but I guess the menu commands are only for the menus in the top of the app.. Any help to make me understand this better will make me happy (until I discover the next problem)

At this point some screenshots of the app itself would be very helpful. :wink:


This is the right-click menu that gave me that info from the FWA tool. I made a macro using right mouse and some key strokes but some times the menu has more lines and I was unstable. It would be nice to do it directly..

Im at home now and wanted to do some more testing on my laptop but when I try FWAT hovering over the same right-click menu I only get this:

application Process "Live"
window

Nothing else.. I will try some more when I get back to the studio tommorow morning

I tried UI Browser to see if that coulf help me find some stuff in the right-click menus but no luck. I did discover that the windows om plugins are called floating.. Is there a script to close all floating windows without closing Live? I tried your suggestion with "click button 1.. window 1" and that also worked for one window at a time - but will also try to close Live when no more floating windows are left. Here is a link to a screencast showing the return of UI Browser:
https://f.io/QrAEucs_
Thanks

Im back at the studio again and found out that the reason I got a lot more out of UI Browser here is that I’m a beta tester for Ableton and apparently some of the beta versions gives out info and the retail version does not. Im under NDA so I can’t share any thing from the closed beta but the right click menu is the same.
How is the retail app hiding all the UI info? If I manage to make something work from the info I get from UI Browser will it still work on the release version.. the closed version that gives almost no info. Like in the video. What I mean is, can I call some of the “hidden” menus if its not “shown” to the OS? Hope this makes sense.. I’m a sound designer not a coder.. But I really like to use KM to make all my tasks easier!

Plugin windows in Live always contain the / character:

Therefore, if we want to close all plugin windows, for example, we might be able to use AppleScript to close every window that contains /:

tell application "System Events"
    tell process "Live"
        set windowList to every window whose name contains "/"
        
        repeat with aWindow in windowList
            tell aWindow
                click (button 1 whose subrole is "AXCloseButton")
            end tell
        end repeat
    end tell
end tell

Ableton's UI isn't scriptable. You'll notice that UI Browser's Screen Reader doesn't update as you move the cursor around the interface. With that in mind, here's one approach for selecting 16th under Fixed Grid:

Fixed Grid- 1-16.kmmacros (22 KB)

Macro screenshot

It presumes that the centre of the screen will always be right-clickable in order to show the context menu. This may not be the case, but it's a good start.

1 Like

Thanks! The fist macro works flawlessly. I like it, and evan understand it a little bit :wink: What if you wanted to close them one by on starting from the active plugin-window?

The 1/16 I cant get working. It seams like its not doing any thing.. will investigate.. I also allready had a mcro that used the arrowkeys to select it but it was a bit unstable.. I have reached out to a max for live programmer and asked if it can be done i m4l.. Thaks a lot for your help!

Try this:

tell application "System Events"
    tell process "Live"
        set windowList to every window whose name contains "/"
        
        if (count of windowList) is greater than 0 then
            tell item 1 of windowList
                click (button 1 whose subrole is "AXCloseButton")
            end tell
        end if
    end tell
end tell

Did you enable the macro? If it's greyed-out, then it's disabled.

thanks! will try. yes the macro is enabeld

Does literally nothing happen? That doesn't sound right. You should at least see the context menu flash up.

sorry. the macro group was not enabled.. I forgot you could also disable a whole group.. Its working now but not as intended.. Problem is the right click menu is a bit dynamic and sometimes has more lines of text I think.. I will try to tweak your macro a bit.
edit: I just tried the close single plugin and it works! Only minor thing is th I get a right-click menu if I run it with no plugin windows, (if Im to fast to close vindows and run it one time more than I have plugins open) Its a minor thing and Im so pleased with the result

Ok here's another option. I have a feeling the poor reliability of your found image attempt was due to timing. Thanks to KM v11, we can now make use of the Wait for Image function, which means we don't need to use static pauses.

Fixed Grid - 1-16th (Found Image).kmmacros (30 KB)

Macro screenshot

You definitely shouldn't be getting a right click from that AppleScript. Are you running it as part of another macro? Regardless, here's another option that should close any plugin window that has focus:

Close Front Plugin Window.kmmacros (21 KB)

Macro screenshot

The right click was indeed an old macro hidden away in all my testing..
The wait for fund image is working great now. I did some editing of it as I woud like to have it work in arrange view and clip view. No need to move the mouse.
I also sat the range to "front window" I was getting mixed results from the pixel range.. dont know why but when the rightclick menu was hovering above the mouse pointer (when the mouse is near the lower screen edge) It was not working. I dont know if a right click menu gets "front window" or the find image has to look at the whole ableton window? That could be troublesome..

Thanks a lot so far!

Btw I saw your post about double tapping streamdeck and I have a feeling you have made a lot of great macros for DAWs - do you share them some place? I would like to get ideas to what is possible.

1 Like

Fixed Grid - 1:16th (Found Image) 2.kmmacros (29.9 KB)

1 Like

The found image check was limited to an area of 300x300px below-right of the current mouse coordinates, in order to guard against other similar images that might cause confusion (e.g. if the global quantize value is set to 1/16).

As long as the context menu appears below and to the right of the click position, it should work.

I don't actually use Live, but I do use Logic Pro.

The thing is that I usually have the midiclip window low on the screen so the right-click menu apears over the mouse. It looks like its working fine with just the "front window" so I will try that for some time.
The "restore mouse position" was also nice! Just brought that back in the new macro.

Thanks for the Megathread.. Will have a look, and I guess there is some things to learn!

1 Like