Tag: ui automation

AutomationElement使用Inspect.exe显示,但在使用UIAutomationCore.dll或System.Windows.Automation时不显示

TL; DR :我做错了导致工作区窗格显示在Inspect Objects中但未显示在我的自定义代码中? 我正在尝试为第三方程序编写一些UI自动化。 我正在使用Windows SDK附带的Inspect.exe ,我已经尝试过System.Windows.Automation和直接COM调用 (使用来自UIA Verify的包装器库)。 Process[] processes = Process.GetProcessesByName(“Redacted Client”); if (processes.Length == 0) throw new Exception(“Could not find \”Redacted Client\” process”); PropertyCondition parentFileCond = new PropertyCondition(AutomationElement.ProcessIdProperty, processes[0].Id); PropertyCondition workspaceCond = new PropertyCondition(AutomationElement.NameProperty, “Workspace”, PropertyConditionFlags.IgnoreCase); PropertyCondition documentCond = new PropertyCondition(AutomationElement.NameProperty, “Untitled3”, PropertyConditionFlags.IgnoreCase); var parentElement = AutomationElement.RootElement.FindFirst(TreeScope.Children, parentFileCond); var workspaceElement = […]

使用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 […]

C#:如何检测屏幕阅读器是否正在运行?

如何检测屏幕阅读器是否正在运行(JAWS)? 正如我在.NET 4中所理解的,我们可以使用System.Windows.Automation.Provider命名空间中的AutomationInteropProvider.ClientsAreListening ,但是如果我必须为.NET 2.0做什么呢? 我试图检查ClientsAreListening源代码,它从RawUiaClientsAreListening库调用外部RawUiaClientsAreListening方法。 您对如何在.NET 2.0中实现JAWS检测有任何想法吗?

使用UI自动化获取Firefox URL

我试图使用以下代码在Firefox中获取URL的值。 问题是它只返回“搜索或输入地址”(参见下面的Inspect.exe树结构)。 看起来我需要降低一级。 有人可以告诉我如何做到这一点。 public static string GetFirefoxUrl(IntPtr pointer) { AutomationElement element = AutomationElement.FromHandle(pointer); if (element == null) return null; AutomationElement tsbCtrl = element.FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.NameProperty, “Search or enter address”)); return ((ValuePattern)tsbCtrl.GetCurrentPattern(ValuePattern.Pattern)).Current.Value as string; } 对于树结构,请参阅:

使用C#从另一个应用程序的SysListView32中的数据网格中读取单元格项

我试图使用C#.net ui-automation和winapi读取另一个进程的SysListView32中的数据网格项 使用ui-automation的C#代码 http://pastebin.com/6x7rXMiW 使用winapi的c#代码http://pastebin.com/61RjXZuK 使用此代码,您只需将鼠标指针放在屏幕上的SysListView32上,然后按Enter键。 现在,两个代码在具有以下属性的单元格项上返回空 pastebin.com/Rw9FGkYC 但这两个代码都适用于以下属性 pastebin.com/L51T4PLu 唯一的区别我注意到name属性包含与单元格中相同的数据,但是当name属性为空时会出现问题。 有没有其他方法来阅读细胞? 或者我可以做的任何改变,请详细说明。

使用自动化框架在textfield / textbox上设置文本并获取更改事件

我想使用Mircosoft UI Automation框架在textfield / textbox元素上设置文本,这意味着在ControlType.Edit或ControlType.Document的AutomationElement 。 目前我正在使用TextPattern从其中一个AutomationElements获取文本: TextPattern tp = (TextPattern)element.GetCurrentPattern(TextPattern.Pattern); string text = tp.DocumentRange.GetText(-1).Trim(); 但是现在我想在AutomationElement设置一个新文本。 我在TextPattern类中找不到这个方法。 所以我正在尝试使用ValuePattern但我不确定这是否是正确的方法: ValuePattern value = element.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern; value.SetValue(insertText); 还有其他方法来设置文本值吗? 另一个问题是如何在Edit / Document元素上更改文本时获取事件? 我尝试使用TextChangedEvent但是在更改文本时我没有触发任何事件: AutomationEventHandler ehTextChanged = new AutomationEventHandler(text_event); Automation.AddAutomationEventHandler(TextPattern.TextChangedEvent, element, TreeScope.Element, ehTextChanged); private void text_event(object sender, AutomationEventArgs e) { Console.WriteLine(“Text changed”); }

WPF UI自动化问题

这个线程属于这个 我在问我需要从哪里插入解决方法 我有一个WPF应用程序,在Windows 7的某些客户端上存在性能问题。在Windows XP上,所有工作都很快。 该应用程序有一个MainShell和一些Child-Windows。 MainShell有时在某些机器上挂起,子窗口也是如此。 现在,我是否必须从所有窗口中的上述链接的线程中插入变通方法? 还有其他解决方法吗?

System.Windows.Automation非常慢

System.Windows.Automation非常慢。 我执行: element.FindAll(TreeScope.Children, Condition.TrueCondition); 在非常快的计算机上获得仅30个子元素可能需要1000毫秒。 我甚至看到它在QT应用程序中获取Tree的子元素时永远悬空。 这是一个已知的问题吗? 谷歌搜索后我找不到任何有用的答案。

如何从任何窗口获取选定的文本(使用UI自动化) – C#

我有一个小托盘应用程序,它注册一个系统范围的热键。 当用户在任何应用程序中的任何位置选择文本并按下此热键时,我希望能够捕获所选文本。 我目前正在使用AutomationElements这样做: //Using FocusedElement (since the focused element should be the control with the selected text?) AutomationElement ae = AutomationElement.FocusedElement; AutomationElement txtElement = ae.FindFirst(TreeScope.Subtree,Condition.TrueCondition); if(txtElement == null) return; TextPattern tp; try { tp = txtElement.GetCurrentPattern(TextPattern.Pattern) as TextPattern; } catch(Exception ex) { return; } TextPatternRange[] trs; if (tp.SupportedTextSelection == SupportedTextSelection.None) { return; } else { […]

Selenium:从文件系统拖放到webdriver?

我必须测试一个Web应用程序,其中包含一个拖放区域,用于从本地文件系统上载文件。 我的测试环境基于C#。 对于我使用过Selenium的自动化测试,但是无法从文件系统中拖动文件。 上传区域是div标签(无input标签)。 那么最好的方法是什么? AutoIt(可以放入网络浏览器)吗? Sikuli?