Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find EVERY accessible object in an application
Hello QM Forum,

This is one amazing piece of software you guys have here! Ive been using it for while now and need some assistance. I am trying to write a macro that will be used for software regression testing. To start, i would like the macro to go through the entire program and list every accessible object in a tree style view (like windows explorer does). I have decided to start small, so im using the Windows Calculator since its such a small application and should be easy to test on.

Once i have a list of all buttons, i would like to run a macro that would click the buttons i need to do a simple math operation (ex. 12x5+40=) and then output the buttons that were clicked to a text file (12 x 5 + 40 =)

i have search and found some code examples on the forum and have this so far:

Copy      Help
out ;;clear output
str saveTo = "$desktop$\output.txt"
str data

Acc a=acc("" "OUTLINE" win("My Computer" "ExploreWClass") "SysTreeView32" "" 0x1000) ;;captured with Find Accesible Object dialog
Acc a1
str s ss
a.Navigate("f" a1) ;;first item
,ss.set(9 0 val(ss))

,data.formata("%s%s[]" ss s)

,a1.Navigate("n"); err break

this would be exactly what i would like it to do, only i would like it to start from the highest parent level. What i would like to see in the end is the same results i get in the bottom output window of the "Find Accessible Objects" dialog after dragging the "DRAG" cross-hair over the outside border of Windows Calculator (capturing the entire application), then have the output send to a text file in a tree-style view.

Thanks for such a great program and the hours of help you provide everyone!
To get all child/descendant objects, use a callback function.

Macro Macro1615
Copy      Help
int w=win("Calculator")
Acc a=acc(w)
str s
a.GetTreeAsText(s) ;;without invisible/useless
;a.GetTreeAsText(s 16|32) ;;all
out s

Member function Acc.GetTreeAsText
Copy      Help
function str&s [flags] ;;flags: acc flags: 16 +invisible, 32 +useless, 64 immediate

acc "" "" a "" "" flags|0x8000 &Acc_GTAT_Proc &s

Function Acc_GTAT_Proc
Copy      Help
function# Acc&a level str&s

str sr sn st.all(level 2 9)


s.formata("%s%s %s[]" st sr sn)

ret 1
Thank you Gintaras,

This is exactly what i was looking for! Though i noticed that i do not see any output for the "Scientific View". It seems like its the same window but i have to switch it to the other view and rerun the program to get the new list. Is there a way to combine the list?
If in standard view scientific buttons are hidden, a.GetTreeAsText(s 16) will show them. If they don't exist, will not show.
Ok, i understand. Thanks again
acc "" "" a "" "" flags|0x8000 &Acc_GTAT_Proc &s

I've been looking at this line of code and I've been trying to understand what each part of it means, and I can't get a good answer on what it is. I was wondering if you could explain the parts I am missing.

acc = accessible object
"" = anything
"" = anything
a = ?
"" = anything
"" = anything
flags = flags
| = ?
0x8000 = callback function flag
&Acc_GTAT_Proc = reference to function Acc_GTAT_Proc
&s = reference to variable s

That single line of code is gathering all the information from a tree. I would like to understand what each part of the code is doing. Explanation would be much appreciated.
Function acc enumerates all descendant objects of a. For each descendant object it calls callback function Acc_GTAT_Proc.
a is member of this variable (variable for which is called this function (GetTreeAsText)). It is COM pointer to the accessible object. We can use it in this function because this function is member function.
|0x8000 adds flag 0x8000 which tells that we use callback function.
Acc_GTAT_Proc gets some properties of the object and adds to the str variable.
Thank you for explain the code for me.

Forum Jump:

Users browsing this thread: 1 Guest(s)