c# - Using Windows.Automation, can I locate an AutomationElement by regex? -
i have object tree has row objects within table parent. i'm attempting set these rows automationelementcollection
automationelementcollection asdf = parenttableobj.findall ( treescope.children, new propertycondition ( automationelement.nameproperty, "i want utilize regex here" ) ); all of rows' automationelement.nameproperty contains string "row". however, variations of string - e.g. "row1", "row2", "toprow", ...
it seems may missing since findall method allows define treescope , find automationelement, matches provided condition parameter. want status unrestricted since can command find scope treescope.
//example : automationelement element = findfirstdescendant( automationelement.fromhandle(windows_hwnd), (ele)=>regex.ismatch( ele.current.name, pattern) ); //the generic method find descendant element: public static automationelement findfirstdescendant(automationelement element, func<automationelement, bool> condition) { var walker = treewalker.controlviewwalker; element = walker.getfirstchild(element); while (element != null) { if (condition(element)) homecoming element; var subelement = finddescendant(element, condition); if (subelement != null) homecoming subelement; element = walker.getnextsibling(element); } homecoming null; }
c# windows automation ui-automation automationelement
No comments:
Post a Comment