AutoHotkey Community

It is currently May 27th, 2012, 12:05 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject:
PostPosted: February 5th, 2012, 10:04 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
Note to Moderator - this thread could be moved to Scripts & Functions, since it is no longer a Wish List thread.

Lexikos wrote:
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.

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group