Front Window Analysis Tool Using AppleScript System Events (List UI Elements)

Chris, I'm glad you can, but I'm not sure the rest of us could. :wink:

Any chance you could work your RegEx magic and produce a simple statement at the top as to whether or not the window is GUI-scritable?

If so, a report like the one UI Browser produces would be really helpful.

Here's an example:
EN Mac 6.6 UI Elements.txt

Here’s a related script from that I have used a few times.
The output is readable.

Coerce GUI scripting information into string?

Hey Folks,

Updated to version 1.01.
Now requires Yosemite or greater.

It's faster and many of the chevron-codes are now replaced with human-readable names. (There are a lot of codes, so I certain to have missed some.)

I've added a property at the top of the script that allows switching the output between TextEdit and the default text editor set in the Finder's Get-Info dialog. (If you haven't changed it on your system then the default is TextEdit.)


Window Analysis Tool for System Events v1.01.kmmacros (7.3 KB)

1 Like

Sow how long before it can generate AppleScript or JXA code to manipulate these things?

Just kidding. Well, kind of, anyway. Welcome to Peter’s world of “it’s never enough”. :stuck_out_tongue:

«class splr» 1 of splitter group 1

is one of this in Path Finder

Chris, do you look for such feedback?


Hey Folks,

Changes to this version (1.50):

  • Faster.
  • No more chevron-codes to worry about.
  • Hierarchical view.

In my opinion BBEdit (or its freeware sibling TextWrangler) is a better vehicle for viewing this output than TextEdit. One reason for this is the ability to turn on “Show Tab Stops”, which makes the view of the hierarchy clearer (some other programming editors also have this feature).


Window Analysis Tool for System Events v1.50.kmmacros (7.6 KB)


Hey Alain,


But that version is obsolete now.  :sunglasses:


I cannot stop me to show an example of use of this so nice tool (I have needed) for UI players:


Here's what it looks like with “Show Tab Stops” turned on instead of “Show Invisibles”.

You know, it's funny you posted this. I was wondering today if there's any sort of native way to display hierarchical data on the Mac. For example, here's the plist view from Xcode:

Another possibility would be to output XML. Most browsers support reading XML and collapsing nodes, etc. I could probably shake the dust off my XML skills if you needed help.

In any case, great work!

Scratch that. Atom has a decent collapsible view. Good enough.

Hey Dan,

Interesting thought.

Here's how it looks in Script Debugger.

tell application "System Events"
   tell application process "TextEdit"
      front window
   end tell
end tell

I'm not going to fiddle with transforming it to XML at the moment, but I have an osax that might make that easy – so I'll think about it.

I'm not aware of any freeware hierarchical viewers for the Mac other than Xcode. I have a great utility called PlistEdit Pro that's much lighter weight than Xcode (but also more expensive).


Well, yeah - Xcode is free, isn't it? :slight_smile:

I’ll keep thinking on this. Seems to me there’s got to be a way to create a good view, in HTML. I’m not an HTML wiz by any means, but if I come up with something I’ll let you know.

You just focus on giving us good results. We’ll focus on everything else. :smile:

Are you talking about normal code-folding?

Or is there something better?


With Atom, you can collapse each node and level. I don’t think you can collapse all or expand all, but at least it helps hide the stuff you’re not interest in.

I pasted you output into it, and it works fine.

Atom > Edit > Folding > Fold All | Unfold All


1 Like

Chris, that is HUGE! :thumbsup:

The SD Results Explorer Window gives you a great drill-down of the UI for whatever app it is focused on.

1 Like

Yep.  :smile:

Script Debugger is an absolute game-changer for AppleScripters.

The forthcoming Script Debugger 6 will have significant upgrades that support AppleScriptObjC.

Hopefully Script Debugger 7 down the road will also support JXA.


Don't leave home without it. It is inconceivable to do more than a little work in AppleScript and not use this. Don't the the price dissuade you: it will repay itself month after month, possibly week after week, or even day after day.

UI Browser too. It not only shows UI structure but writes pieces of AppleScript for you.


Unfortunately (so far), no JXA support. From the web site:

Script Debugger 5 does not support the new JavaScript for Automation feature introduced by Apple in Yosemite (Mac OS X 10.10).

Ironically, we once offered our own JavaScript implementation for Script Debugger versions 2 and 3 and discontinued it due to lack of interest. We are watching how much adoption Apple’s JavaScript for Automation receives. Offering debugging for Apple’s JavaScript implementation is non-trivial so this isn’t something we can easily add back into Script Debugger.

If sufficient interest in JavaScript for Automation develops we will seriously consider adding it to Script Debugger, or possible create a JavaScript specific version of the product.