Quantcast
Channel: Windows Desktop Development for Accessibility and Automation forum
Viewing all articles
Browse latest Browse all 585

How to get name / value from custom control like the Inspect tool does from Microsoft?

$
0
0

Does anybody know how to get the name/value of an AutomationElement of custom control type? Please see the image with the link below. I am interested in getting the name/value of the highlighted AutomationElement that Inspect tool by Microsoft is able to get. I tried checking if the AutomationElement supports IAccessible since from the Inspect tool since IsLegacyIAccessiblePatternAvailableProperty is true. I didn't have much luck with the following snippet of codes and all I got was empty string for all children of the AutomationElement of table Control (the parent of the highlighted AutomationElement in the image). Please advise.

AutomationElement sibling = TreeWalker.RawViewWalker.GetFirstChild(table);

            while (sibling != null)
            {

                if ((Boolean)sibling.GetCurrentPropertyValue(AutomationElementIdentifiers.IsLegacyIAccessiblePatternAvailableProperty))
                {
                    var pattern = ((LegacyIAccessiblePattern)sibling.GetCurrentPattern(LegacyIAccessiblePattern.Pattern));
                    var name = pattern.GetIAccessible().accValue;

                    //allChildren.Add(sibling);
                    if (((string)name).IndexOf(deviceId) != -1)
                    {
                        AutomationElement device = TreeWalker.RawViewWalker.GetPreviousSibling(sibling);

                        if (device != null)
                        {
                            checkBox = TreeWalker.RawViewWalker.GetPreviousSibling(device);
                            break;
                        }
                    }
                }

                sibling = TreeWalker.RawViewWalker.GetNextSibling(sibling);
            }


Viewing all articles
Browse latest Browse all 585

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>