C# 使用WinAPI从ProBrowser控件捕获数据
我试图读取非托管应用程序中控件的行。我一直在使用ManagedWinapi包装pinvokes,在很大程度上,它让我达到了我需要的位置。我可以找到控件(它是一个ProBrowser类,不确定它到底是什么)和视图属性,但我需要的信息都不可用。相反,ProBrowser有九个子元素,所有文本框都具有匹配的属性:C# 使用WinAPI从ProBrowser控件捕获数据,c#,windows,winapi,C#,Windows,Winapi,我试图读取非托管应用程序中控件的行。我一直在使用ManagedWinapi包装pinvokes,在很大程度上,它让我达到了我需要的位置。我可以找到控件(它是一个ProBrowser类,不确定它到底是什么)和视图属性,但我需要的信息都不可用。相反,ProBrowser有九个子元素,所有文本框都具有匹配的属性:Password:false、MultiLine:false和Text:。我假设这些是列标题,但是没有太多可供参考的内容。这是我所能得到的最底层的信息,在任何级别上我似乎都无法访问列表的实际内
Password:false、MultiLine:false
和Text:
。我假设这些是列标题,但是没有太多可供参考的内容。这是我所能得到的最底层的信息,在任何级别上我似乎都无法访问列表的实际内容
SystemWindow list = new SystemWindow(ptr); // latching onto the ProBrowser
SystemWindow[] pieces = list.AllDescendantWindows; // same results if using .AllChildWindows
foreach (SystemWindow y in pieces) {
ManagedWinapi.Windows.Contents.TextContent tc = (ManagedWinapi.Windows.Contents.TextContent)y.Content; // ListContent returns null here and on the parent control
Console.WriteLine(tc.LongDescription);
Console.WriteLine(tc.ComponentType);
foreach (KeyValuePair<string, string> kvp in tc.PropertyList) {
Console.WriteLine("\t" + kvp.Key + ", " + kvp.Value);
}
Console.WriteLine("\tText: " + GetText(y.HWnd));
}
systemwindowlist=newsystemwindow(ptr);//锁定在ProBrowser上
SystemWindow[]片段=list.AllDescendantWindows;//如果使用.AllChildWindows,结果相同
foreach(系统窗口分块){
ManagedWinapi.Windows.Contents.textc=(ManagedWinapi.Windows.Contents.TextContent)y.Content;//ListContent在此处和父控件上返回null
控制台写入线(tc.LongDescription);
Console.WriteLine(tc.ComponentType);
foreach(tc.PropertyList中的KeyValuePair kvp){
Console.WriteLine(“\t”+kvp.Key+”,“+kvp.Value”);
}
Console.WriteLine(“\tText:+GetText(y.HWnd));
}
GetText
只是GetWindowText
的包装器。它可以很好地返回其他控件(如按钮)的文本,但不会从ProBrowser中提取任何内容
现在我被卡住了。我不知道如何从列表中抓取数据,因为它似乎没有出现在任何可访问的地方。如果有帮助的话,我已经提供了一个相关窗口的截图
使用QTP Quick Test Professional 10版,您可以获取probrowser对象内部的值。您应该使用
.GetVisibleText.
我们在自动化脚本中使用了相同的方法。使用QTP Quick Test Professional 10版,您可以获得probrowser对象内部的值。您应该使用
.GetVisibleText.
我们在自动化脚本中使用相同的控件。如果它不是ListView,则它是一个自定义网格控件。你完成了,你看不懂。Drats,这正是我担心的。试试UI间谍工具()。您还可以尝试另一个工具:SysExporter()。如果这些工具可以读取它,那么它是可能的,否则您可能无法读取。如果它不是ListView,那么它是一个自定义网格控件。你完成了,你看不懂。Drats,这正是我担心的。试试UI间谍工具()。您还可以尝试另一个工具:SysExporter()。如果这些工具可以阅读,就有可能做到,否则你可能做不到。