我的窗体上有一个TreeView控件,我从窗口本身开始递归地遍历另一个窗口的元素。我正在使用它来查找元素:getRecursiveElements(AutomationElementparent){children=parent.FindAll(TreeScope.Children,Condition.TrueCondition);foreach(AutomationElementchildinchildren){addToTreeView(child);getRecursiveElements(child);}}一般来说,代码在大多数情况下都运行良好。树已填充,我有一些其他支持代码允