Note to Moderator - this thread could be moved to Scripts & Functions, since it is no longer a Wish List thread.
tinku99 wrote:
Code:
accChild := ComObj(9, ComObjQuery(aChild
, "{618736e0-3c3d-11cf-810c-00aa00389b71}"), 1)
Children.Insert(accChild ? accChild : aChild)
I think you'll find that accChild will always be used, since ComObj() returns an object even if the pointer is NULL.
Yes - I finally noticed that Sean queried for the IAccessible pointer in the original Acc Library on Acc_Parent/Child. So, if an IDispatch pointer is in the varChildren structure from a Acc_Children call, but we Query for the IAccessible pointer, both pointers would need released, correct? Also, I think it would be better if Acc_Children just returned an AHK Array. I don't see a practical direct use of the current Acc_Children function
(which just wraps AccessibleChildren DllCall) if Acc_Children returned an AHK Array with the IAccessible pointers already queried & wrapped. I plan to replace the current Acc_Children function with the following, unless someone provides a reasonable objection:
Code:
Acc_Children(Acc) {
Acc_Init()
try cChildren:=Acc.accChildCount, Children:=[]
if DllCall("oleacc\AccessibleChildren", "Ptr", ComObjValue(Acc), "Int", 0, "Int", cChildren, "Ptr", VarSetCapacity(varChildren,cChildren*(8+2*A_PtrSize),0)*0+&varChildren, "Int*", cChildren)!=0 { ; Notify the user if Acc_Children call fails
error := Exception("",-1)
MsgBox, 262420, SCRIPT ERROR, % "Function: Acc_Children`nFile:`t"
. error.file "`nLine:`t" error.line "`n`nContinue Script?"
IfMsgBox, No
ExitApp
return
}
Loop %cChildren% {
i := (A_Index-1)*(A_PtrSize*2+8)+8
child := NumGet(varChildren,i)
Children.Insert(NumGet(varChildren,i-8)=3? child
: ComObj(9,ComObjQuery(child,"{618736e0-3c3d-11cf-810c-00aa00389b71}"),1) )
ObjRelease(child) ; <-- Need to release the IDispatch pointer? (shouldn't hurt anything if it's a ChildId)
}
return Children
}
Additionally, I was planning on adding the following functions:
Code:
Acc_Location(Acc, ChildId=0) {
Acc.accLocation(ComObj(0x4003,&x:=0), ComObj(0x4003,&y:=0), ComObj(0x4003,&w:=0), ComObj(0x4003,&h:=0), ChildId)
return {x:NumGet(x,0,"int"), y:NumGet(y,0,"int"), w:NumGet(w,0,"int"), h:NumGet(h,0,"int")
, pos:"x" NumGet(x,0,"int")" y" NumGet(y,0,"int") " w" NumGet(w,0,"int") " h" NumGet(h,0,"int")}
}
Acc_Parent(Acc) {
return ComObj(9, ComObjQuery(Acc.accParent,"{618736e0-3c3d-11cf-810c-00aa00389b71}"), 1)
}
... or perhaps we should just add an Acc_Query function instead of Acc_Parent/Child? I am open to any suggestions on these functions.