Reputation: 41
I'm working on automating a windows application. I'm using the teststack white framework. I've hit a problem. This program has a 'Window' object that I cannot see inside of. White shows no controls inside of it. The Inspect.exe shows no controls inside of it either when running in UI Automation mode. If I switch Inspect to MSAA it see the controls inside just fine. Is there anyway for me to use MSAA from C# to get a handle on these controls?
Upvotes: 4
Views: 3891
Reputation: 3646
If you can identify the MSAA functions you need, you can use P/Invoke to call them from C#. Here's an example article about doing that with MSAA:
http://www.codeproject.com/Articles/38906/UI-Automation-Using-Microsoft-Active-Accessibility
Also, pinvoke.net can be used to identify the IAccessible (MSAA) functions:
http://www.pinvoke.net/search.aspx?search=IAccessible&namespace=[All]
Here's another SO answer along those lines:
Finally, as an alternative to P/Invoke, you might also be able to use Tlbimp.exe to create a wrapper assembly for oleacc.dll, and access the MSAA functions through it. I'm not sure if that works with MSAA, but it's worth a try.
As an example, here's a C# hello world example I wrote that shows how to use the UI Automation COM interface from C#, using an assembly created with Tlbimp.exe:
As mentioned in the comments in that file, as of the Windows 7.1 SDK, generating an assembly with Tlbimp.exe looked like this:
"%PROGRAMFILES%\Microsoft SDKs\Windows\v7.1\bin\tlbimp.exe" %windir%\system32\UIAutomationCore.dll /out:interop.UIAutomationCore.dll
Upvotes: 5