本文整理汇总了C#中IUiElement.FindFirst方法的典型用法代码示例。如果您正苦于以下问题:C# IUiElement.FindFirst方法的具体用法?C# IUiElement.FindFirst怎么用?C# IUiElement.FindFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUiElement
的用法示例。
在下文中一共展示了IUiElement.FindFirst方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetWindowCollectionByPid
internal List<IUiElement> GetWindowCollectionByPid(
IUiElement rootElement,
WindowSearcherData data)
{
classic.AndCondition conditionsForRecurseSearch = null;
var elementsByProcessId =
new List<IUiElement>();
// 20141001
// if ((null != data.Name && 0 < data.Name.Count()) ||
if ((null != data.Name && data.Name.Any()) ||
!string.IsNullOrEmpty(data.AutomationId) ||
!string.IsNullOrEmpty(data.Class)) {
data.Recurse = true;
}
var conditionWindowPaneMenu =
new classic.OrCondition(
new classic.PropertyCondition(
classic.AutomationElement.ControlTypeProperty,
classic.ControlType.Window),
new classic.PropertyCondition(
classic.AutomationElement.ControlTypeProperty,
classic.ControlType.Pane),
new classic.PropertyCondition(
classic.AutomationElement.ControlTypeProperty,
classic.ControlType.Menu));
foreach (int processId in data.ProcessIds) {
conditionsForRecurseSearch =
new classic.AndCondition(
new classic.PropertyCondition(
classic.AutomationElement.ProcessIdProperty,
processId),
new classic.PropertyCondition(
classic.AutomationElement.ControlTypeProperty,
classic.ControlType.Window));
var conditionsProcessId =
new classic.AndCondition(
new classic.PropertyCondition(
classic.AutomationElement.ProcessIdProperty,
processId),
conditionWindowPaneMenu);
try {
if (data.Recurse) {
if (data.First) {
IUiElement rootWindowElement =
rootElement.FindFirst(
classic.TreeScope.Children,
conditionsProcessId);
if (null != rootWindowElement) {
elementsByProcessId.Add(rootWindowElement);
}
} else {
IUiEltCollection rootCollection =
rootElement.FindAll(
classic.TreeScope.Children,
conditionsProcessId);
if (null != rootCollection && 0 < rootCollection.Count)
{
elementsByProcessId.AddRange(rootCollection.Cast<IUiElement>());
}
}
} else {
if (data.First) {
IUiElement tempElement =
rootElement.FindFirst(
classic.TreeScope.Children,
conditionsProcessId);
if (null != tempElement) {
elementsByProcessId.Add(tempElement);
}
} else {
IUiEltCollection tempCollection =
rootElement.FindAll(
classic.TreeScope.Children,
conditionsProcessId);
if (null != tempCollection && 0 < tempCollection.Count) {
elementsByProcessId.AddRange(tempCollection.Cast<IUiElement>());
}
}
//.........这里部分代码省略.........