Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing Array Names
#1
Hello,

I am working on changing an accessible object array element into a different name without changing the whole array. I have an idea of what it should look like, but I know it is wrong, and will not work as I want it to. This is what I have so far:
Code:
Copy      Help
int w=win("Calculator" "SciCalc")
Acc a.Find(w "WINDOW" "Calculator" "class=SciCalc" 0x1005)

ARRAY(Acc) b
Acc Backspace
str name
str role
str data
int i
int x y cx cy

a.GetChildObject(-1 "" "" "" 16)
for i 0 b.len
,name=b[i].Name
,b[i].Role(role)
,b[i].Location(x y cx cy)

,if objectrole="PUSHBUTTON"
,,if x=291 y=125 cx=65 cy=29
,,,b[i]=Backspace

,data.formata("%i %s %s %i[]" i objectrole objectname x y cx cy)
#2
Why need to change name?
If you want to change name property of the accessible object, it's impossible.
#3
I don't want to change the property names of an accessible object. I want to change the name of an array element so i can call it into another function more easily. Right now there were some objects without a name i would have to do an out statement for data to allow me to view element number, object roles, names and location. Then use the b[element number] if i am able to change the name of the element then i could access it without going through all that trouble.
#4
You can associate names with array elements using an IStringMap variable.
Macro Macro1784
Code:
Copy      Help
IStringMap m=CreateStringMap

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

ARRAY(Acc) b
str name
str role
str data
int i
int x y cx cy

a.GetChildObjects(b -1 "" "" "" 16)
for i 0 b.len
,name=b[i].Name
,b[i].Role(role)
,b[i].Location(x y cx cy)

,if role="PUSHBUTTON"
,,if x=291 and y=125 and cx=65 and cy=29
,,,m.IntAdd("Backspace" i) ;;give name "Backspace" to this array element

,data.formata("%i %s %s %i %i %i %i[]" i role name x y cx cy)


;now you can map name to index
if m.IntGet("Backspace" i) ;;if "Backspace" exists
,out i
,b[i].Mouse
#5
Thank you very much. This is exactly what i needed


Forum Jump:


Users browsing this thread: 1 Guest(s)