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 only get the first level. There are bunch of UIElements and arrays under each item. I think it has to do with Applescript returning object specifier, but not actual object? I'm not sure how to invoke name of the object specifier as function. I tried objproperty, obj.property(), eval("obj." + property + "()"), ,and none of them works. I also tried iterate(app.windows())[0]
Thank you for your help.