I am just testing the new KM11 Button scanner and am impressed. I need to add a couple of new Macros for a couple of things i was too lazy to ^^
However, I've hit a bit of a problem. My goal was to make a macro that toggles my Gmail profile using the button scan function. Everything goes smoothly when I click on my profile icon in the top-right corner, revealing the dropdown menu. But here's the problem, when I switch over to Keyboard Maestro to scan the next button, the dropdown menu disappears.
Any of you know a workaround for this? Maybe a shortcut I'm not aware of? Fyi I'm aware of the image search method, but I'm keen on utilizing this shiny new feature
Edit: I marked Peter's post as solution, as you can find titles for buttons via those tools. As it turns out, what I needed to interact with wasn't actually a button.
For another issue alias pressing a button that contains something check out Alexander's reply. You can use regex!
Thank you for recommending the AccessibilityInspector! After taking a closer look, I've noticed that the overlay mainly consists of HTML elements grouped together, with links rather than actual buttons for my other accounts. So, even if I were to scan specifically for buttons, they wouldn't show up....
As a workaround, I'll use image search for this particular task, although I must say the new button scan feature is damn cool
One small suggestion for improvement: it would be quite useful if there were an option to "Press Button that Contains" certain text. This would come in handy in scenarios where the first part of a button's label remains constant, but the latter part changes like accounts, for instance. So a button labeled "Google-Account: James" might later change to "Google-Account: James work." Even though it's technically the same button and your script could still function, it would have to be manually adjusted or a if else case added.
^Google-Account: James would match (and in this case press) either “Google-Account: James” or “Google-Account: James work”, as both begins with the search string. If you’d want to press a button that 'contains' a string, not only 'beginning with' it, ^? seems to do this. (All though I am not proficient enough in regex to be sure if ^? is the expression to emulate 'contains' behaviour the most perfectly.)
Holy moly....I didn’t know that regex is possible in "press button". This is amazing! @peternlewis I am once again impressed!
Thank you @Alexander for pointing this out, that is very helpful and solves a couple of other cases I had plus this one!
activate application "Logic Pro X"
tell application "System Events"
tell process "Logic Pro X"
click button 13 of UI element 1 of UI element 1 of group 3 of list 1 of group 2 of window "Untitled - Tracks"
Unfortunately, because the position of the button in the UI element tree changes as you interact with the channel strip (add plugins/sends etc), this isn't a real solution. I was hopeful that the new button press functionality would allow me to click the button via its descriptor, but alas no such luck.
Regardless, I'm impressed with how quickly the action identifies compatible buttons via their descriptor. In my attempts to script that kind of thing, it's always been slllloooowwww.