TUTORIAL VIDEO: Using UI Browser and Keyboard Maeastro

I just posted a quick and dirty tutorial video for how to use UI Browser with Keyboard Maestro.

It's not nearly up to my normal standards, but I knew if I didn't just get it done, I'd never do it. Sorry about so much zooming and panning. And the audio quality - I just used my iMac mic, not my pro mic.

Regardless of the quality, I hope this shows that even if all this UI Browser stuff is Greek to you, you don't actually have to understand much of it to make use of it. Just follow the steps.

So if you want an introduction to UI Browser, so you can do things like checking to see if a checkbox is checked, or "checking" a checkbox, or how to tell if a UI field is enabled or disabled, this ought to help.

Feel free to ask questions. If you feel like you have to offer critiques or ways to improve the video, I'm willing to bet I already know them all. Like I said, this was a "fly by the seat of my pants" thing, and I really do know how to do better.

Have I given enough excuses yet? :slight_smile:

12 Likes

Sorry, I don't have time for amateaur videos.
I'll wait the for pro ver to be released.

LOL

Except for whining about not having time, 15 times, I thought it was a great video. :smile:

Just to ping your ego a bit, you said you know everything about making videos. I guess you forgot the one about no need to point out your flaws in advance. A simple, "Here's a quick, unpolished, uncut, video . . ." will do.

Don't let this go to your head, but your rough video is at least 10x better than most "polished" videos I have seen, like on YouTube.

So, go ahead, just "point and shoot".

I do have one serious constructive criticism: You moved too fast.

I'm sure you know this, but you forgot because you were in a hurry. What seems obvious, and slow, to you, will be mystifying and fast to someone who has never used the product. Of course, that's what pause and rewind are for . . .

Keep up the good work.

1 Like

Exactly! Thanks for the compliments, by the way. I've always been my worst critic.

Yep, talked too fast, moved too fast, skipped some topics I could have covered, or covered more thoroughly. As they say in "Tin Cup", "Perfection is unattainable." :slight_smile:

"Perfection" is not at issue here.
As one of my former bosses used to say:
"Better is the enemy of good enough".

We had more than one serious discussion about that statement. :smile:

OMG, if only I had learned that early in life... That's pretty-much the story of my life.

Hey Dan,

Well done.  :smile:

Note: there are hotkeys for quicker access to several functions.

Scope out the “Highlight” and “Follow Focus” checkboxes in the second image.

-Chris

1 Like

Took some thought but great advice, I'll have to remember that more often, while not using it as an excuse for mediocrity.

Thanks for the video Dan.

1 Like

Thank you very much for creating this. Extremely useful.

1 Like

Thanks @DanThomas, very useful.

Failed trying to get AppleScript to rightsize Finder Columns using UI Browser 2.8.0

Obvious issue with selected item disappearing from UIB so no AppleScript being created. Posted video goes thru the details. Any suggestions would be appreciated.

https://www.icloud.com/iclouddrive/02BSaOKFsT0BLzMbrLMQXrn8w#AS_Size_Finder_Columns_-_Screen_Recording

I get this error:

image

I apologize. I didn’t think thru what sharing an iClould link means and deleted the file mistakenly thinking it was uploaded rather than linked :face_with_raised_eyebrow:.

https://www.icloud.com/iclouddrive/02BSaOKFsT0BLzMbrLMQXrn8w#AS_Size_Finder_Columns_-_Screen_Recording

I’ve re-linked it. Thanks Dan!

My experience has been that with popup menus, you can't use UI Browser, because the popup menu goes away, as you've seen.

So when I'm automating popup menus, once the menu pops up, I use keystrokes to select the menu item. So, arrows, or letters that jump to an item.

The only problem is with menus that you can't count on what item is selected when it pops up (like drop-down menus), so you may use the wrong number of arrow keystrokes, or if you're use a letter, if there's a duplicate, it can go to the wrong element.

So for that situation, when the menu pops up, I do whatever it takes to move the "cursor" to the top item first, so it's always consistent. Sometimes the home key works to move the cursor to the top, other times I've had to repeat an up arrow keystroke the maximum number of items in the popup menu.

You could also use found images, but that has its own set of problems.

Hope this helps! By the way, I've used these techniques a bunch of times, so if you have issues, just ask.

1 Like

Yes, there was a macro that sorta worked when the column separators had a small double vertical line at the bottom of the column for a found image. Those lines went away with Mojave. It wasn't very reliable and I stopped using it anyway.

I've UI hacked a lot given my very limited scriping skills. In this particular case there's no way I see to evoke the menu without actually manually clicking on the divider which mutes the point.

Think I have any luck with Script Debugger 7? Thanks Dan!

You can't find the location of the divider using UI scripting? Because once you know the location, you can just use KM to automate right-clicking on it.

This may not help at all, but I'm just throwing this out there. I do a lot of automating of Final Cut Pro X. One of the trickiest parts (for me, anyway) was to find some of the UI elements, which can be in different containers depending on, well, I'm not exactly sure what. I think it has to do with what's visible when you launch the app, but I'm not positive.

So I've got some JXA code which looks at various containers and lists, etc. to find the elements I want. Like this:

win.splitterGroups[0].groups[group1Index].splitterGroups[0].groups[group2Index].splitterGroups[0].groups[0].splitterGroups[0].scrollAreas[0].tables[0]

And I loop through group1Index from 0 to 2 (or whatever it is), and inside that, group2Index from 0 to 4, or whatever, until I find my target.

Then I store the indexes that worked in KM variables. The next time the script gets called, it first tries the stored indexes and uses them if they're still valid, otherwise it repeats the search.

This may or may not help. Probably not. But very few people will appreciate what I've done, so I had to share it, knowing at least you'd understand. :roll_eyes::stuck_out_tongue:

2 Likes

Good idea, UIB gave me code for the divider resulting in this when adding a tell block generated by UIB:

activate application "Finder"

tell application "System Events"
   tell process "Finder"
      try
         tell scroll bar 1 of scroll area 2 of scroll area 1 of browser 1 of splitter group 1 of splitter group 1 of window "TOL"
            set {xPosition, yPosition} to position
            set {xSize, ySize} to size
         end tell
         -- modify offsets if hot spot is not centered:
         click at {xPosition + (xSize div 2), yPosition + (ySize div 2)}
      end try
   end tell
end tell

It does something as I can see the shadow for the window change when I run it the first time a Finder window is brought forth.

The cursor doesn't move and I don't know how to add a right click into the script so I'm unclear about what it's doing.

Also, this seems coded for a particular window or window title "TOL" and will need to be generalized for any Finder Window.

Another pointer please...

Also, I don't know ANYTHING about using JXA code. Is there a KM Macro to paste it into that would execute the code?

Well, the only way I know how to right-click is using KM. So you'd have to return the coordinates from the AS code to KM, and go from there.

As for which window, title, I'm not sure. This is starting to sound like we need @ccstone to help. HELP, Chris! :smile:

1 Like

You might try and/or modify this script by @ccstone. It works fine for me:

Script: Set Finder List View Column Width for Name and Date

1 Like

Hey Guys,

This is list-view rather than column view.

Resize Columns in the Finder’s List View – Macro

This should give you an idea of what to do.

If you need more help then I need to see a picture of the window you're trying to script.

-Chris

Hi @JMichaelTX,

Wellll... It works as advertised and maybe if I can convert it from working with list view to column view and set it up to work with two-four columns and get around the issue of it seeming to be fixed at a width of 400, it'd be a usable workaround.

Given a couple of guys who know their way around AS are puzzling their way thru it and I’m WAY back at the beginning of learning AS, I’m not likely to do too much more than poke at this a bit before putting it down.

I’m not asking for spoon feeding. I know I need to learn more basic stuff before tackling something like this head on AND the effort to read this example and see others work on it gleans me some info which is good! Soooo...

Thank you for pointing to this example!

I suppose that without all this little irritations and limitations we just be working :wink: