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

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

-Chris

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?

-Chris

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.

-Chris

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.

Really.

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.

Hi I can’t seem to get this to work for the application named ‘Daylite’

I get this error message as the result:

/var/folders/ct/lsmxdhzn2hv4p378kqlxxf8c0000gn/T/Keyboard-Maestro-Script-2FB29C27-5AC2-401E-9945-A6DC96D73819:1133:1148: execution error: System Events got an error: AppleEvent timed out. (-1712)

Is anybody else experiencing this bug too?

Hey Ali,

Are you talking about Daylite from Market Circle?

-Chris

I downloaded the app, and my analysis tool works fine with it.

UI Browser has some problems with it though and can crash when trying to get certain information.

-Chris

Hi ccstone, thank you for your response, how do I overcome the problem that I am facing?

Hey Ali,

How could I possibly know?

If I can't reproduce exactly what you're doing and test – then I can't help much.

You could join the newly formed UI Browser Users Group and provide more information about what you're doing.

Perhaps someone in the group has used Daylite.

-Chris

In fact using BBEdit as editor folding is just around the corner... the simple tuning is to change ".txt" file name extension in ".py" in this AppleScript handler:

Explanation:

The conventions to encode in a compact way the hierarchy of the GUI elements are identical to that of the Python code: it is therefore enough to take full advantage of this homology by transforming the temporary text file into a pseudo Python file, by changing the extension, so that BBEdit automatically activates the folding :wink:

Before:

After
For example, "scroll bar 1" elements are folded:

-Alain

3 Likes

@alain, that's very clever! :+1:

Indeed!

Somehow I always knew that Python must be good for something. :grin:

3 Likes