Tag: microsoft ui automation

如何使用UI自动化库单击“窗格”?

我们有一个应用程序,我需要单击一个窗格。 我尝试使用以下代码,我用它来单击一个按钮,但它给出了不支持的模式exception。 InvokePattern click_pattern = (InvokePattern)adjust_button.GetCurrentPattern(InvokePattern.Pattern); click_pattern.Invoke(); 还有其他办法吗?

如何在没有实现任何模式的情况下操作控件?

我正在尝试通过UIAutomation为我们的项目实施自动化测试。 但是很多控件都不是标准的,并且对于那些控件也没有实现正确的模式。 在这种情况下,我应该如何通过UIAutomation框架操纵控件? 例如,我们产品中的按钮是通过窗格实现的,调用的模式也没有实现。 我该如何点击按钮? (为了避免在测试机上安装VS,我不想在Microsoft.VisiualStudio.TestTools.UITesting命名空间中使用Mouse.Click() )有没有办法只使用UIAutomation框架或.net中嵌入的其他内容框架? 提前致谢! (如果实现了正确的模式,下面的代码将起作用。作为新用户,我无法发布截图供您参考,抱歉!) object temp = null; if (btnTest.TryGetCurrentPattern(InvokePattern.Pattern, out temp)) { InvokePattern btnTestPattern = temp as InvokePattern; btnTestPattern.Invoke(); }

UI自动化不适用于DataGridView

在尝试了几种解决方案之后,我迫切需要帮助。 我尝试了几种方法,然后才最终复制并仍然坚持使用UIAutomation获取Datagrid的完整内容的解决方案。 让我们谈谈代码,请考虑以下评论: // Get Process ID for desired window handle uint processID = 0; GetWindowThreadProcessId(hwnd, out processID); var desktop = AutomationElement.RootElement; // Find AutomationElement for the App’s window var bw = AutomationElement.RootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ProcessIdProperty, (int)processID)); // Find the DataGridView in question var datagrid = bw.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, “dgvControlProperties”)); // Find all rows from the […]

一段时间后,UI自动化事件在监视应用程序后停止接收,然后在一段时间后重新启动

我们正在使用Microsoft的UIAutomation框架来开发一个客户端,该客户端监视特定应用程序的事件并以不同方式响应它们。 我们已经开始使用该框架的托管版本,但由于延迟问题,请转到包含在UIACOMWrapper中的本机版本。 在我们(大规模)WPF应用程序中出现更多性能问题后,我们决定将其移至单独的终端应用程序(通过UDP将事件传输到我们的WPF应用程序),这似乎解决了所有性能问题。 唯一的问题是,似乎每隔几分钟,TabSelection,StructureChanged,WindowOpened和WindowClosed的事件就会被捕获几分钟。 令人惊讶的是,当发生这种情况时,仍会收到并处理PropertyChanged事件。 我将发布我们的事件监视器的相关代码,但这可能无关紧要,因为我们在使用Microsoft自己的AccEvent实用程序时看到了类似的行为。 我不能发布受监控应用程序的代码,因为它是专有的和机密的,我可以说它是一个承载WPF窗口的WinForms应用程序,也非常庞大。 有没有人在使用UI自动化框架时看到过这种行为? 感谢您的时间。 这是监视器代码(我知道事件处理在这里的UI自动化线程上,但是将它移动到专用线程并没有改变任何东西): public void registerHandlers() { //Register on structure changed and window opened events System.Windows.Automation.Automation.AddStructureChangedEventHandler( this.getMsAutomationElement(), System.Windows.Automation.TreeScope.Subtree, this.handleStructureChanged); System.Windows.Automation.Automation.AddAutomationEventHandler( System.Windows.Automation.WindowPattern.WindowOpenedEvent, this.getMsAutomationElement(), System.Windows.Automation.TreeScope.Subtree, this.handleWindowOpened); System.Windows.Automation.Automation.AddAutomationEventHandler( System.Windows.Automation.WindowPattern.WindowClosedEvent, System.Windows.Automation.AutomationElement.RootElement, System.Windows.Automation.TreeScope.Subtree, this.handleWindowClosed); this.registerValueChanged(); this.registerTextNameChange(); this.registerTabSelected(); this.registerRangeValueChanged(); } private void registerRangeValueChanged() { if (this.getMsAutomationElement() != null) { System.Windows.Automation.Automation.AddAutomationPropertyChangedEventHandler( this.getMsAutomationElement(), System.Windows.Automation.TreeScope.Subtree, this.handlePropertyChange, System.Windows.Automation.RangeValuePattern.ValueProperty); […]

使用System.Windows.Automation读取Edge Browser Title和Url

我正在尝试从Microsoft EDGE浏览器中读出TITLE和URL。 最好使用System.Windows.Automation执行此操作,因为代码库已经将此用于其他问题。 是否可以使用System.Windows.Automation? 如何访问URL? 我现在这么远: AutomationId “TitleBar” ClassName “ApplicationFrameWindow” Name = [string] => Reading out this element gives me the TITLE => Walking it’s children, I find the item “addressEditBox”: AutomationId “addressEditBox” ClassName “RichEditBox” Name “Search or enter web address” => I always get back the string “Search or enter web address” => This […]