0

I would like to retrieve the scrollArea size and position of Google Chrome using AppleScript (JXA). (my goal is to get the client area size).

I am unable to find the corresponding UIElement inside the hierarchy.

Here is the JXA code:

function inspect(obj, depth) {
    var indent = "".padStart(3*depth)   
    for (var i in obj) {
        if(obj[i] instanceof Array) {
            inspect(obj[i])
        } else if(obj[i] instanceof Object){
            console.log(`${indent}(${obj[i].position()}, ${obj[i].size()}) ${obj[i].class()}/${obj[i].role()}:: ${obj[i].name()}`)
            inspect(obj[i].uiElements(), depth + 1)
        }
    }
}

var sysEv = Application('System Events')
var app = sysEv.processes['Google Chrome']
inspect(app.windows(), 0)

However, the macOS Accessibility Inspector can find it:

enter image description here

Any clues? Thanks for your help!

JCB
  • 116
  • 1
  • 4
  • I suggest you solve it in AppleScript first. That way you only have to wrestle with GUI Scripting’s awfulness, rather than fight both GUI Scripting *and* JXA’s own defects combined. Also, never used it myself but you may find [UI Browser](https://pfiddlesoft.com/uibrowser/) helpful. – foo Feb 11 '20 at 19:20
  • Thanks @foo. I tried UI Brower and it shows exactly the same UI element hierarchy as mine. I think we can't find the scroll area that because the scroll area may belong to a Chrome child process. – JCB Feb 12 '20 at 20:56

0 Answers0