LegacyIAccessible in Windows.Automation
How to obtain LegacyIAccessib开发者_开发百科le.State and others LegacyIAccessibles of AutomationElement with C# ? just like Inspect.exe from tools makes it.
The LegacyIAccessible
is new and is not available in the .NET level as is in .NET 4.0. But there is a project on CodePlex that has a newer implementation that in change set 38718 added support for this.
Be beware that you have to compile the project from source, the latest binary release is too old to contain this unfortunately...
What you want to do is something like:
if ((bool) child.GetCurrentPropertyValue(AutomationElementIdentifiers.IsLegacyIAccessiblePatternAvailableProperty)) {
var pattern = ((LegacyIAccessiblePattern) child.GetCurrentPattern(LegacyIAccessiblePattern.Pattern));
var state = pattern.GetIAccessible().accState;
// Do something with state...
}
The comments in the source code says that these are new features for Windows 7, but I get it to work on Windows XP SP3...
Hope this helps!
/AZ
精彩评论