Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
enumeration of items
#1
Hello,

I have a program that does not have strings built for some objects. Some of the objects are within the same tree. Whenever I use one of the objects it would point to the first object with the name. I then switched over to using ID numbers, but when I upgraded my software all the numbers changed. I was wondering if there was a way to gather the items within a tree and place them into an array of some kind and renaming to how I want.

Example: There are three ("" "" (Calculator) (SciCalc) "" 0x100) and i want to find by using a for loop that searches, and then if one was found it would name it Calc1. Second would be Calc2 and so on.

Any help would be great thank you.
#2
Try GetChildObjects.

example
Macro Macro1763
Code:
Copy      Help
int w=win("Options" "#32770") ;;QM Options dialog
Acc a.Find(w "PROPERTYPAGE" "" "class=#32770" 0x1004)
ARRAY(Acc) b
a.GetChildObjects(b)
int i
for i 0 b.len
,out b[i].Name
#3
It seems that my QM version is older so I do not have the find option. Is there a way around the find option? I do have the find accessible object, but the result of using it ends up being something like

Acc a=acc("View site information" "GRAPHIC" win("Quick Macros Forum • Post a reply - Google Chrome" "Chrome_WidgetWin_1") "Chrome_WidgetWin_1" "" 0x1001)
#4
GetChildObjects also is new. Need QM 2.3.3.
The Find line can be replaced with acc.
#5
Since i have an older version of QM before GetChildObjects and Find. Do you have any advice for me of getting around this?
#6
Use callback function with acc. Read more in acc help.

Other way - Navigate.
example
Macro Macro1764
Code:
Copy      Help
int w=win("Options" "#32770") ;;QM Options dialog
Acc a=acc("" "PROPERTYPAGE" w "#32770" "" 0x1004)
a.Navigate("first")
rep
,out a.Name
,a.Navigate("next"); err break
#7
I upgraded Quick Macro to 2.3.3.7. I tried to use the code with the find and GetChildObject, but I keep getting errors.

Code:
Copy      Help
int w=win("Calculator" "SciCalc") ;;QM Options dialog
Acc a.Find(w "PROPERTYPAGE" "" "SciCalc" 0x1004)
ARRAY(Acc) b
a.GetChildObjects(b)
int i
for i 0 b.len
,out b[i].Name

my error is "invalid argument." using that code.
#8
In which line error?
#9
Acc a.Find(w "PROPERTYPAGE" "" "SciCalc" 0x1004)

at the a.Find
#10
Delete that line and add new with "find accessible object" dialog.
#11
OK i set up the syntax so it is able to compile, but i am only getting information on 1 part of the tree instead of the whole thing. Got anymore ideas?

P.S. thanks for all your help so far Gintaras

Code:
Copy      Help
int w=win("Calculator" "SciCalc") ;;QM Options dialog
Acc a.Find(w "" "Calculator" "class=SciCalc" 0x1004)
ARRAY(Acc) b
a.GetChildObjects(b)
int i
for i 0 b.len
,out b[i].Name
#12
Look in GetChildObjects help.

a.GetChildObjects(b -1)
#13
Ok I read all of the GetChildObjects help. I know that the -1 is to get all descendants of all levels. I plugged the -1 in as you did "a.GetChildObjects(a -1)" but i get the same result as when i did not have the -1 plugged in.

I also looked at the examples "a.GetChildObjects(c -1 "LINK")". I changed LINK with an *, but nothing changed then i switched to using just empty quotes still nothing happened. Am I missing something big, because i know there are more then just "Help Topics" and "About Calculator" within the tree.
#14
Role is missing in Find. Finds wrong object.

all objects in Calculator
Macro Macro1761
Code:
Copy      Help
out
int w=win("Calculator" "SciCalc")
Acc a.Find(w "WINDOW" "Calculator" "class=SciCalc" 0x1005)
ARRAY(Acc) b
a.GetChildObjects(b -1)
int i
for i 0 b.len
,str sRole sName
,b[i].Role(sRole)
,sName=b[i].Name
,out F"{sRole} {sName}"

all links in Internet Explorer
Macro Macro1766
Code:
Copy      Help
out
int w=win("Internet Explorer" "IEFrame")
Acc a.Find(w "PANE" "" "" 0x3000 3)
ARRAY(Acc) b
a.GetChildObjects(b -1 "LINK")
int i
for i 0 b.len
,str sName sValue
,sName=b[i].Name
,sValue=b[i].Value
,out F"{sName} | {sValue}"
#15
Thank you for your last post Gintaras. It helped me out a lot, but I am working on the final point. I am trying to appoint every object as its own element. I've been reading ARRAY help, but I am not able to get the code to work. I also tried to edit based off of
ARRAY of custom type as parameter
but still doesn't work or unable to follow. I removed all my edits, because I think the edits made the code worse. My current code is

Code:
Copy      Help
int w=win("Calculator" "SciCalc") ;;QM Options dialog
Acc a.Find(w "WINDOW" "Calculator" "class=SciCalc" 0x1005)
ARRAY(Acc) b.create(0x10000)
ARRAY(str) names.create(0x10000)
int i

a.GetChildObjects(b -1)
for i 0 b.len
,names[i]=b[i].Role
,names[i+1]=b[i].Name
,b[i].Role(names[i+2])
,
,out F"{names[i]} : {names[i+2]} : {names[i+1]}"

i need it so that "names[i]" does not repeat ever. Help would be grateful.

Thank you
#16
Cannot add or change object properties.

If you get objects with GetChildObjects, you have array. For example, to click 3-th object use b[2].DoDefaultAction.

Or use match index with Find. Then don't need GetChildObjects and array. Example:
Code:
Copy      Help
int w=win("Calculator" "")
Acc a1.Find(w "PUSHBUTTON" "" "class=Button" 0x1004 0 1)
Acc a2.Find(w "PUSHBUTTON" "" "class=Button" 0x1004 0 2)
Acc a3.Find(w "PUSHBUTTON" "" "class=Button" 0x1004 0 3)
#17
How do i check which element each object is pointed to?
#18
run this macro
Macro Macro1761
Code:
Copy      Help
out
int w=win("Calculator")
Acc a.Find(w "" "Calculator" "" 0x1005)

ARRAY(Acc) b
int i

a.GetChildObjects(b -1 "PUSHBUTTON")

for i 0 b.len
,;out b[i].Name
,int x y
,b[i].Location(x y)
,str s=i
,OnScreenDisplay s 1 x y 0 14 0 2
#19
Gintaras that is an awesome macro/program, but I am trying to find out what array number goes with each object so it is easier to access them. I want to assign the array numbers with my own name.
#20
Cannot assign names.
#21
Ok is there a way to display the numbers the object names and roles are associated with?
#22
,out F"{i} {sRole} {sName}"
#23
Yes!!! that is perfect ^_^ thank you sooo much Gintaras. This will make things go sooo much faster XD
#24
I am sorry to call upon your powers once more, but after i have gathered the information i want Array Element, Role, and Name within my array. Is there a way to store the array as a baseline? Baseline as in an array that is placed with all the elements, roles, and names stored. Whenever i run the macro it look at all the excising a elements before trying to gather more elements without overwriting the current.

I was reading

List Box items

but I am not filtering yet.
#25
Where the array should be saved? In memory, in file (text/CSV or database), or in registry?
#26
A file would be best i believe because I can always call it in, while memory may get erased.
#27
Data should be stored as a table with columns ROLE and NAME? And then will need to open the table and find names in it? And if name not found, add new row?
#28
I was thinking of something close to a 3D array, but not really a 3D array. It would be three different arrays one for element, one for role, and one for name. If there is a new element/role/name it would add new line within each array.
#29
What is purpose of this project?
#30
I need to do a regression test on my company's program, but many of the buttons do not have names attached so click on objects based off names is useless. If I do it based off ID it is also useless because the IDs will change when I upgrade the software. I need a way to have a baseline for all the regression tests. So the best way I can think of right now is to gather all the objects in an array, and do a DoDefaultAction on the array element to hit the buttons. If I keep the code as it is the code would be useless because if the developer adds a new object in between element 66 and 67 it would push every element down by one and all the objects being clicked would do something completely different from what I am expecting.


Forum Jump:


Users browsing this thread: 1 Guest(s)