TUTORIAL VIDEO: Using UI Browser and Keyboard Maeastro



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.



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.


Thank you very much for creating this. Extremely useful.


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.



I get this error:



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:.


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.


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:


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:


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"
         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:


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


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.



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:


Don't be afraid to ask Chris (ccstone) questions. He's got an incredible knowledge of these kinds of things, and doesn't mind helping. He just needs to know specifically what you're trying to do. The fact that you're trying to learn is even better!

So his last reply said he needs a picture of the window before he can help. I'd take him up on that - post a picture!

@JMichaelTX Jim, you might want to split this to a new topic. It's been too long for me to remember how to do this.


Hey Chris,

Here's a typical 1/4 size of the screen Finder window (MacOS 10.14.3, KM 8.2.4) I work with, with the target contextual menu item selected.

Often, I have that A-Z list first which only needs a minimal width column tho the starting column could be the smart folders TOL, Shortcut, or Open Items which all need more width so a fixed width solution is only going to be a workaround.

Ideally, the function would trigger with each new Finder window AND I suppose if the trigger also included a focused window/focused window title changes, then it would continue to adjust when new folders are selected.

Sidebar- this functionality was enough to tip the scales to buy a Path Finder (8.3.8) license for as it has this function but it proved too unstable so I've benched it for now.

Thanks Chris, Dan, and Jim.


I haven't tried this, but I've seen some good reviews. It's called Path Finder. They have a free trial, I think. Just a thought.


Yup, good thought. I recently tried it and found it too unstable for my setup. I’ll let it age for awhile and check again after some more updates. Some folks seem to be doing ok with it suggesting that it may be my setup that’s not playing nice with it. Just not compelling enough at this moment to dig further.

It does right size the column widths which was nice for the couple of weeks it ran before starting to hang.