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
Cheers,
Frozen
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.
You can actually emulate this as of now. By adding a ^ at the beginning of the button text field it will match using Regular expression. Press a Button [Keyboard Maestro Wiki]
^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"
end tell
end tell
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.
Two possibilities - there are multiple matching buttons and the one you are referring to is disabled, or the button is disabled but nonetheless responds to the click action.
There are only two buttons called Channel Mode in the front window (one for the current channel and one for its destination buss) and they both show up in the new button scanner.
The button doesn't have an enabled/disabled state per se. It's a toggle between mono and stereo channel mode and the button press action sees it as 'disabled' in both states.
Without access to the application so I can duplicate it, I can't say as to why.
Maybe there are more than one matching such elements (the scanning system would detect such things). Maybe the app returns different values at different times. I don't know I'm afraid.
If you can duplicate the issue on something I have access to, then I can take a further look.
Otherwise, I have added some debugging code for the next version that you can try which will report more of what it sees in this case.