OSDN Git Service

IAccessible NVDAObject's parent property: hack around annoying MSAA implementations...
authorMichael Curran <mick@kulgan.net>
Wed, 22 Sep 2010 01:32:39 +0000 (11:32 +1000)
committerMichael Curran <mick@kulgan.net>
Wed, 22 Sep 2010 01:32:39 +0000 (11:32 +1000)
source/NVDAObjects/IAccessible/__init__.py

index c14b0d5..de00909 100644 (file)
@@ -815,7 +815,14 @@ the NVDAObject for IAccessible
                        return super(IAccessible,self).parent\r
                res=IAccessibleHandler.accParent(self.IAccessibleObject,self.IAccessibleChildID)\r
                if res:\r
-                       return self.correctAPIForRelation(IAccessible(IAccessibleObject=res[0],IAccessibleChildID=res[1]),relation="parent") or super(IAccessible,self).parent\r
+                       parentObj=IAccessible(IAccessibleObject=res[0],IAccessibleChildID=res[1])\r
+                       if parentObj:\r
+                               #Hack around bad MSAA implementations that deliberately skip the window root IAccessible in the ancestry (Skype, iTunes)\r
+                               if parentObj.windowHandle!=self.windowHandle and self.IAccessibleRole!=oleacc.ROLE_SYSTEM_WINDOW and winUser.getAncestor(self.windowHandle,winUser.GA_PARENT)==parentObj.windowHandle:\r
+                                       windowObj=Window(windowHandle=self.windowHandle)\r
+                                       if windowObj and windowObj.parent==parentObj:\r
+                                               return windowObj\r
+                       return self.correctAPIForRelation(parentObj,relation="parent") or super(IAccessible,self).parent\r
                return super(IAccessible,self).parent\r
 \r
        def _get_next(self):\r