AutomationElement 不检索不可见元素
AutomationElement does not retrieve unvisible elements
我试图获取我的 Skype 程序中的所有元素(包括所有聊天选项卡),但我只获取可见项。
这是代码:
var window = AutomationElement.RootElement.FindFirst(TreeScope.Subtree,
new PropertyCondition(AutomationElement.ClassNameProperty, "tSkMainForm"));
if (window != null)
{
var items = window.FindAll(TreeScope.Subtree, Condition.TrueCondition);
//DO SOME CODE...
}
项目属性不包含所有不可见的项目(例如,与某人聊天的内部细节,比方说,Dan)。但是如果在我的 Skype 上打开与 Dan 的聊天,那么项目 属性 也会包含与 Dan 聊天的内部细节。
即使在我的 Skype 中未打开选项卡,我也希望项目 属性 具有聊天内部详细信息。
为什么我的代码没有检索到所有数据?我如何获取所有数据(包括所有聊天选项卡,即使它们未打开)?
迭代所有 GridControl 行,使用 GridControlAutomationPeer 的 IScrollProvider 接口实现
private void Button_Click_1(object sender, RoutedEventArgs e) {
var p = Process.GetProcessesByName(ProcName).FirstOrDefault(x => x != null);
if (p == null) {
Console.WriteLine("proccess: {0} was not found", ProcName); return;
}
var root = AutomationElement.RootElement.FindChildByProcessId(p.Id);
AutomationElement devexGridAutomationElement = root.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, DevexGridAutomationId));
if (devexGridAutomationElement == null) {
Console.WriteLine("No AutomationElement was found with id: {0}", DevexGridAutomationId);
return;
}
var cond = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.DataItem);
var devexGridItems = devexGridAutomationElement.FindAll(TreeScope.Descendants, cond);
GridPattern gridPat = devexGridAutomationElement.GetCurrentPattern(GridPattern.Pattern) as GridPattern;
Console.WriteLine("number of elements in the grid: {0}", gridPat.Current.RowCount);
}
我试图获取我的 Skype 程序中的所有元素(包括所有聊天选项卡),但我只获取可见项。
这是代码:
var window = AutomationElement.RootElement.FindFirst(TreeScope.Subtree,
new PropertyCondition(AutomationElement.ClassNameProperty, "tSkMainForm"));
if (window != null)
{
var items = window.FindAll(TreeScope.Subtree, Condition.TrueCondition);
//DO SOME CODE...
}
项目属性不包含所有不可见的项目(例如,与某人聊天的内部细节,比方说,Dan)。但是如果在我的 Skype 上打开与 Dan 的聊天,那么项目 属性 也会包含与 Dan 聊天的内部细节。 即使在我的 Skype 中未打开选项卡,我也希望项目 属性 具有聊天内部详细信息。
为什么我的代码没有检索到所有数据?我如何获取所有数据(包括所有聊天选项卡,即使它们未打开)?
迭代所有 GridControl 行,使用 GridControlAutomationPeer 的 IScrollProvider 接口实现
private void Button_Click_1(object sender, RoutedEventArgs e) {
var p = Process.GetProcessesByName(ProcName).FirstOrDefault(x => x != null);
if (p == null) {
Console.WriteLine("proccess: {0} was not found", ProcName); return;
}
var root = AutomationElement.RootElement.FindChildByProcessId(p.Id);
AutomationElement devexGridAutomationElement = root.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, DevexGridAutomationId));
if (devexGridAutomationElement == null) {
Console.WriteLine("No AutomationElement was found with id: {0}", DevexGridAutomationId);
return;
}
var cond = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.DataItem);
var devexGridItems = devexGridAutomationElement.FindAll(TreeScope.Descendants, cond);
GridPattern gridPat = devexGridAutomationElement.GetCurrentPattern(GridPattern.Pattern) as GridPattern;
Console.WriteLine("number of elements in the grid: {0}", gridPat.Current.RowCount);
}