Could someone please help me to make a script that reports all the children and its properties of an uielement? It's similar to entireContents() function. Here's my recursive function.
function iterate(obj) {
for (var property in obj) {
if(obj[property] instanceof Array) {
console.log("Array: " + property + "," +obj[property])
iterate(obj[property])
} else if(obj[property] instanceof Object){
console.log("Object: " + property + ',' + obj[property])
iterate(obj[property])
} else {
console.log("Unknown: " + property +"," + obj[property]);
}
}
}
iterate(app.windows())
I presume you want to use the commands in the Processes Suite
of "System Events".
UIElement
, you must use one of these properties:(accessibilityDescription, class, description, enable, entireContents, focused, help, maximumValue, minimumValue, name, orientation, position, role, roleDescription, selected, size, subrole, title, value)
obj[i].name()
.To get all UIElements from an UIElement, you must use obj[i].uiElements()
Here's an example on the windows of the "TextEdit" process.
function iterate(obj) {
for (var i in obj) {
if(obj[i] instanceof Array) {
iterate(obj[i])
} else if(obj[i] instanceof Object){
console.log("Object: " + i + ': name = ' + obj[i].name() + ', value = ' + obj[i].value() + ', class = ' + obj[i].class() + ', description = ' + obj[i].description())
iterate(obj[i].uiElements())
}
}
}
var sysEv = Application('System Events')
var app = sysEv.processes['TextEdit']
iterate(app.windows())