Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
duplicate array objects
#1
Hello,

I currently have a function that gathers all objects (including invisible objects)
Code:
Copy      Help
int w=win("Calculator" "SciCalc")
Acc a.Find(w "WINDOW" "Calculator" "class=SciCalc" 0x1005)

ARRAY(Acc) b
int i
str data
str ress="Resolution :"
str orie="Orientation :"
str saveTo="$desktop$\Macro.txt"
str name role; int x y cx cy

int w1=win("Calculator" "SciCalc")
Acc a1.Find(w1 "WINDOW" "Calculator" "class=SciCalc" 0x1005)
a.GetChildObjects(b -1 "" "" "" 16)
for i 0 b.len
,b[i].Role(role)
,name=b[i].Name
,b[i].Location(x y cx cy)
,data.formata(" %i : %s : %s : %i %i %i %i[]" i role name x y cx cy)

out data
my problem is there are duplicate objects. I want to edit this function so that if there is an object with the same name, role, and location it will not be added to the array.

I was talking with someone and he was saying i could try making a boolean that is declared as false, and if there is a duplicate it will change the boolean to true. If the boolean is true then it will not write to the array.

Any thoughts on how i can edit the current code to work how i want it to?
#2
Here it is easy with IStringMap.
Macro Macro1797
Code:
Copy      Help
;SetCurDir "c:\windows"
;SetCurDir "$qm$"

int w=win("Calculator" "SciCalc")
Acc a.Find(w "WINDOW" "Calculator" "class=SciCalc" 0x1005)

ARRAY(Acc) b
int i
str data
str ress="Resolution :"
str orie="Orientation :"
str saveTo="$desktop$\Macro.txt"
str name role; int x y cx cy
IStringMap m=CreateStringMap

int w1=win("Calculator" "SciCalc")
Acc a1.Find(w1 "WINDOW" "Calculator" "class=SciCalc" 0x1005)
a.GetChildObjects(b -1 "" "" "" 16)
for i 0 b.len
,b[i].Role(role)
,name=b[i].Name
,b[i].Location(x y cx cy)
,str s.format("%s : %s : %i %i %i %i" role name x y cx cy)
,m.Add(s); err continue ;;error if already exists in m
,data.formata(" %i : %s[]" i s)

out data
not tested
#3
This works perfectly!!! thank you so much


Forum Jump:


Users browsing this thread: 1 Guest(s)