0

How to check two IAccessible are Identical at runtime? It seems that there is no method provided by MSAA. I know that

1.we can check multi property of these two IAccessible object, but stirng cmp/string get/role get/role cmp/... may consume lots of time.

2.the simplest way to compare these two object is compare the address, but I failed.

Anyone can show me an example or give me a hint? Thanks very much!

Community
  • 1
  • 1
JYP2011
  • 23
  • 5
  • sounds like a XY problem: https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem what are you trying to do? also: why don't use UI Automation? IAccessible is legacy – Simon Mourier May 22 '20 at 06:45
  • I do a test which search the first matched IAccessible in the same subtree twice, which returned two IAccessible* respectively. And I cout the content of these two point IAccessible*, the result shows two address not the same. So, I thought the result may be caused by the COM Object. Next, I google and use [IsEqualObject](https://paste.ubuntu.com/p/NSQN3QPQMK/) to compare these two, It still return false; @SimonMourier – JYP2011 May 22 '20 at 06:59
  • Because UIAutomation cannot meet my requirement in specicial situation. For example, some application has document which cannot use UIA to access (It cannot open the application's accessibility) @SimonMourier – JYP2011 May 22 '20 at 07:02
  • I know the UIA can give me a more Streamlining UI Tree, can provide more infomation. In fact, I want to mix them to meet my requirement.@SimonMourier – JYP2011 May 22 '20 at 07:04
  • Two requests for IUnknown must always returns the same pointer, so you can try comparing the result of Marshal.GetIUnknownForObject(yourAccessible) but all this smells bad. I'm surprised that some apps can be seen by IAccessible but not by UIA. Have you tried the SDK inspect tool on them just to see what's visible? – Simon Mourier May 22 '20 at 07:48
  • yes, inspect cannot access it too. Specified, inspect cannot see the ui element under the document AutomationElement. Marshal.GetIUnknownForObject(IAccessible) is c# code. And I have used static_cast(ia1) and comparet the two casted IAccessible*. Sadly, the result is false:-(@SimonMourier – JYP2011 May 22 '20 at 10:46
  • Does Marshal.GetIUnknownForObject(yourAccessible) <=> static_cast(yourAccessible) ? @SimonMourier – JYP2011 May 26 '20 at 02:38
  • Sorry, I assumed you we're in .NET. No, you should use QueryInterface: https://stackoverflow.com/a/23403849/403671 – Simon Mourier May 26 '20 at 05:53
  • Bro, I use same point and AccessibleObjectFromPoint function to get IAccessible* plA and IAccessible* plB. Then I use IAccessible's QueryInterface interface to get IUnknown* respectively. They're not the same. I thought the plA and plB is the same IAccesible object inside. – JYP2011 May 26 '20 at 07:48
  • That just means the object is not the same technically. Seems logical, I don't see any reason why two calls to AccessibleObjectFromPoint would give back the same technical IUnknown reference, even if it's the same "visual" object. There's no "identity" concept in MSAA. Hence my suggestion to use UIA that has UIA_RuntimeIdPropertyId and UIA_AutomationIdPropertyId properties: https://learn.microsoft.com/en-us/windows/win32/winauto/uiauto-automation-element-propids – Simon Mourier May 26 '20 at 08:05
  • If I use ElementFromIAccessible to return corresponding AutomatinoElement, does the returned two AutomationElement will have the same runtimeId? Besides, does every AutomationElement have runtimeId? I use Inspect to detect the element under document, detection result shows such element has no aumationId. – JYP2011 May 26 '20 at 08:19
  • I will have a try now – JYP2011 May 26 '20 at 08:20
  • not support @SimonMourier – JYP2011 May 26 '20 at 09:46
  • Hey, bro. What's the different between ID3D11Texture2D and IAccessible? I thought that these two all are based on the COM tech, so why the method which can check equal or not, no suitable for IAccessible? I found if(Marshal.GetUnknownForObject(IAccessible) == Marshal.GetIUnknownForObject(IAccessible)) in github, so I think there exist a method to do it in native. – JYP2011 May 27 '20 at 02:58

0 Answers0