Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# UI自动化和功能区控制_C#_Wpf_Ui Automation - Fatal编程技术网

C# UI自动化和功能区控制

C# UI自动化和功能区控制,c#,wpf,ui-automation,C#,Wpf,Ui Automation,我使用UIAutomation API实现WPF应用程序的自动化。在我点击Ribbon控件之前,一切都很顺利。我可以通过Inspect.exe查看有关Ribbon及其子项的信息,但在代码中我无法获得有关这些元素的信息 换句话说,在此代码中,aeElement始终为空: aeElement = aeForm.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProp

我使用UIAutomation API实现WPF应用程序的自动化。在我点击Ribbon控件之前,一切都很顺利。我可以通过Inspect.exe查看有关Ribbon及其子项的信息,但在代码中我无法获得有关这些元素的信息

换句话说,在此代码中,aeElement始终为空:

aeElement = aeForm.FindFirst(TreeScope.Children,
                  new PropertyCondition(AutomationElement.NameProperty, "XXX"));
我尝试了
TreeScope.substands
TreeScope.Elements
。 我尝试了
AutomationElement.ControlTypeProperty
AutomationElement.automationdProperty
。 我尝试了
TreeWalker
——没有任何效果

想知道这个问题是否有解决方案? 事先非常感谢


编辑:两处都没有答案

最坏的情况是根,对吗? 然后尝试以下解决方案:

a。从根目录开始搜索,然后深入到窗口、上下文,等等

b。如果a不起作用,那一定是你的拼写问题。名称区分大小写


c。你为什么不使用AutomationID?它就是为这种用途而创建的

谁的ribbon控件?它与Microsoft ribbon相关:不,根根本不是问题;肯定没有拼写错误;正如我在问题中提到的,我也尝试了AutomationId属性,但它不工作,所以当您从根目录搜索时,您没有问题吗?如果是这样,请深入搜索。它可能在与其自身的窗口的平行范围内