标签: microsoft-ui-automation

页面上的某些控件对于MS UI Automation不可见

我们有一个带有StartPage.xaml的应用程序,其中TabControl的控件模板定义了一些网格和堆栈面板。在xaml的中间,该模板中有一个itemPresenter,在其下方有一个堆栈面板。尽管对用户而言工作正常,但MS UI自动化只能在项目演示者内部看到选项卡项目,而在模板的同一级别上未定义任何其他项目。我试图在堆栈面板中添加标准按钮,MS UIA看不到该按钮,以检查这是否与我们拥有的自定义用户控件有关,但是MS UIA也不可见该标准按钮。如果使用Snoop,则可以在模板层次结构的相应级别上的snoop树中看到模板中的所有元素。但是MS UIA仍然找不到它们。

使用控件会阻止MS UIA在页面上找到控件的地方会出什么问题?

wpf microsoft-ui-automation

4
推荐指数
1
解决办法
2884
查看次数

使用 Microsoft UI 自动化获取任何应用程序的 TitleBar 标题?

C#VB.Net 中,我如何使用Microsoft UI 自动化来检索包含文本的任何控件的文本?。

我一直在 MSDN 文档中进行研究,但我不明白。

使用 UI 自动化获取文本属性

然后,例如,使用下面的代码,我试图通过提供该窗口的 hwnd 来检索窗口标题栏的文本,但我不知道如何按照标题栏找到子控件(标签?)这确实包含文本。

Imports System.Windows.Automation
Imports System.Windows.Automation.Text
Run Code Online (Sandbox Code Playgroud)

.

Dim hwnd As IntPtr = Process.GetProcessesByName("notepad").First.MainWindowHandle

Dim targetApp As AutomationElement = AutomationElement.FromHandle(hwnd)

' The control type we're looking for; in this case 'TitleBar' 
Dim cond1 As New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TitleBar)

Dim targetTextElement As AutomationElement =
    targetApp.FindFirst(TreeScope.Descendants, cond1)

Debug.WriteLine(targetTextElement Is Nothing)
Run Code Online (Sandbox Code Playgroud)

在上面的示例中,我正在尝试使用标题栏,但只是我想使用任何其他包含文本的控件来执行此操作……例如标题栏。

PS:我知道 P/Invoking GetWindowTextAPI。

.net c# vb.net ui-automation microsoft-ui-automation

4
推荐指数
1
解决办法
3400
查看次数

Windows UI Automation API在服务器上运行时无法查找子元素

我正在使用NUnit 2.5.10测试中的Microsoft UI Automation API来为WPF应用程序执行自动UI测试.

在某些情况下,在我的开发机器上运行测试能够找到某些UI元素,但是当在我们的构建代理机器上针对相同的二进制文件运行相同的脚本时,它无法找到这些元素.

我找不到代理机器行为不同的任何原因.我怀疑它与UIAccess标志或UAC有关,但没有遇到任何具体问题.

任何人都可以提供一些指导,说明构建代理为什么会有不同的行为,或者如何修复代理以查看与其他机器相同的元素?

例如,我有一个comboBox,其中有十几个选项.使用Win7 SDK中的"Inspect Objects"工具,我可以看到每个选项都有一个包含实际显示文本的子元素.所以在我的测试代码中,我做了类似这样的事情:

// get the child elements
var options = comboBoxElement.FindAll(TreeScope.Children, (System.Windows.Automation.Condition) new PropertyCondition(AutomationElement.IsControlElementProperty, (object) true));

foreach (AutomationElement child in viewOptions)
{
    var subControls = child.GetChildren();
    Console.WriteLine("Child: {0} w/ {1} children", child.Current.Name,  subControls.Count);
    foreach (AutomationElement subControl in subControls)
        Console.WriteLine("SubControl: {0}", subControl.Current.Name);
}
Run Code Online (Sandbox Code Playgroud)

在我的开发机器上,我得到了这些结果:

Child: My.BoundObject.ClassName w/ 1 children
SubControl: Displayed Text for first item
Child: My.BoundObject.ClassName w/ 1 children
SubControl: Displayed Text for second item
Child: My.BoundObject.ClassName w/ 1 …
Run Code Online (Sandbox Code Playgroud)

c# nunit-2.5 microsoft-ui-automation

3
推荐指数
1
解决办法
2224
查看次数

如何使用microsoft uiautomation检查复选框?

我需要自动化madvr gui并通过uutoutomation实现平滑运动.
但找不到最近和简单的工作样品.

madvr窗口识别:

madvr平滑动作复选框识别:

我的实际代码:

using System;
using System.Diagnostics;

namespace MadAutomation
{
    class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Enabling the madvr smooth motion feature...");

            EnableSmoothMotion();

            Console.Write("Press any key to continue...");
            Console.ReadKey(true);
        }

        public static void EnableSmoothMotion()
        {
            // Run madvr configuration.         
            Process p = new Process();
            p.StartInfo.FileName = @"C:\Users\Admin\Desktop\madVR\madHcCtrl.exe";
            p.StartInfo.Arguments = "editLocalSettingsDontWait";
            p.Start();

            // Enable smooth motion checkbox.
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c# ui-automation microsoft-ui-automation

3
推荐指数
1
解决办法
2148
查看次数

Microsoft Automation UI 鼠标单击给定位置

我正在开发一个 C# 控制台应用程序,它将打开一个应用程序并在那里执行一些操作。我能够启动应用程序并登录应用程序。我需要在特定位置上进行一些鼠标单击操作,但找不到如何操作。可以模拟吗?我必须使用该位置,因为我需要做的不仅仅是单击按钮或文本框。我需要右键单击主窗口并从打开的菜单中选择某些内容。我不确定是否有办法使用 Microsoft Automation UI 来做到这一点。

提前致谢。

c# microsoft-ui-automation

3
推荐指数
1
解决办法
7625
查看次数

如何将AutomationElement.NativeWindowHandle转换为IntPtr

我有一个AutomationElement A(MS UI Automation),它代表一个组合框.我想使用Windows API调用在该组合框中选择第n项

IntPtr ComboBox_SetCurSel(IntPtr hWnd, int index)
Run Code Online (Sandbox Code Playgroud)

A.NativeWindowHandle包含组合框的句柄,但为了将其传递给ComboBox_SetCurSel,我需要将其转换intIntPtr.

怎么样?

c# winapi microsoft-ui-automation

2
推荐指数
1
解决办法
3252
查看次数

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

我正在尝试从Microsoft EDGE浏览器中读出TITLE和URL.最好使用System.Windows.Automation执行此操作,因为代码库已经将此用于其他问题.

  1. 是否可以使用System.Windows.Automation?
  2. 如何访问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 is the control where the url is in, though it isn't updated as the user goes to a website, it always returns a fixed string.
Run Code Online (Sandbox Code Playgroud)

在代码中: …

c# ui-automation microsoft-ui-automation microsoft-edge

2
推荐指数
1
解决办法
2451
查看次数

有没有办法坚持UIAutomation元素?

我在Windows 7(64位)上使用MS UIAutomation.我想知道是否有可能使UIAutomation元素持续存在,如果是这样,那么可能是起点.

我想出的唯一的东西是元素的RuntimeID,但问题是某些元素可能没有id.

我想要实现的一个简单场景是,我通过使用AutomationElement.FromPoint()它来找出屏幕上控件的UIAutomation元素,现在我想要保留它,以便下次我可以通过"加载"它来轻松访问它UIAutomation Element.

c# microsoft-ui-automation

1
推荐指数
1
解决办法
174
查看次数

Windows UI 自动化。如何自动化Windows资源管理器滚动条?

我正在使用 Windows UI 自动化框架:http : //msdn.microsoft.com/en-us/library/System.Windows.Automation(v=vs.110).aspx

我遇到的问题是微软提供的 UI 自动化框架似乎对某些 Windows 资源管理器视而不见。我可以找到根 AutomationElement“滚动条”,但是我找不到它的子组件,即按钮、位置等。这很奇怪,因为显然很多 WPF 应用程序会使用 Windows 资源管理器来选择文件,因此 Microsoft 会将其视为一个主要错误在其框架内。所以我一定是做错了什么?

在此处输入图片说明

下面的代码演示了我在做什么。root是 Windows 资源管理器 AutomationElement。我验证了这一点,因为我可以看到滚动条项目,因为它有一个自动化 ID。我还验证了它是正确的垂直滚动条,因为 Windows 资源管理器中有两个。

 AutomationElement functionControl = root.FindFirst(TreeScope.Descendants |         
 TreeScope.Element | TreeScope.Subtree,new 
 PropertyCondition(AutomationElement.NameProperty, "Page down"));
Run Code Online (Sandbox Code Playgroud)

c# automation microsoft-ui-automation

0
推荐指数
1
解决办法
1824
查看次数