本文整理汇总了C#中IUiElement.FindAll方法的典型用法代码示例。如果您正苦于以下问题:C# IUiElement.FindAll方法的具体用法?C# IUiElement.FindAll怎么用?C# IUiElement.FindAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUiElement
的用法示例。
在下文中一共展示了IUiElement.FindAll方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SearchByExactConditionsViaUia
internal static List<IUiElement> SearchByExactConditionsViaUia(
IUiElement inputObject,
Hashtable[] searchCriteria,
classic.Condition conditions)
{
if (conditions == null) return new List<IUiElement>();
if (inputObject == null || (int) inputObject.GetCurrent().ProcessId <= 0) return new List<IUiElement>();
IUiEltCollection tempCollection = inputObject.FindAll(classic.TreeScope.Descendants, conditions);
if (null == searchCriteria || 0 == searchCriteria.Length) {
return tempCollection.ToArray().ToList<IUiElement>();
}
return tempCollection.ToArray().Where(element => TestControlWithAllSearchCriteria(searchCriteria, element)).ToList<IUiElement>();
}
示例2: SearchByContainsTextViaUia
internal static List<IUiElement> SearchByContainsTextViaUia(
IUiElement inputObject,
classic.Condition conditionsForTextSearch)
{
IUiEltCollection textSearchCollection = inputObject.FindAll(classic.TreeScope.Descendants, conditionsForTextSearch);
return textSearchCollection.Cast<IUiElement>().ToList();
}
示例3: 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>());
}
}
//.........这里部分代码省略.........
示例4: GetAutomationElementsWithFindAll
internal List<IUiElement> GetAutomationElementsWithFindAll(
IUiElement element,
ControlSearcherData data,
classic.Condition conditions,
bool caseSensitiveParam,
bool onlyOneResult,
bool onlyTopLevel,
bool viaWildcardOrRegex)
{
var resultCollection = new List<IUiElement>();
try {
IUiEltCollection results =
element.FindAll(
classic.TreeScope.Descendants,
conditions);
resultCollection =
WindowSearcher.ReturnOnlyRightElements(
results,
data,
caseSensitiveParam,
viaWildcardOrRegex);
if (null != results) {
// results.Dispose(); // taboo!
results = null;
}
// results = null;
}
catch { //(Exception eWildCardSearch) {
}
return resultCollection;
}
示例5: GetWindowCollectionByName
List<IUiElement> GetWindowCollectionByName(
IUiElement rootElement,
WindowSearcherData data)
{
var windowCollectionByProperties =
new List<IUiElement>();
var resultCollection =
new List<IUiElement>();
if (null == data.Name) {
// 20141001
// data.Name = new string[]{ string.Empty };
data.Name = new []{ string.Empty };
}
classic.OrCondition conditionsSet = null;
if (data.Recurse) {
conditionsSet =
new classic.OrCondition(
new classic.PropertyCondition(
classic.AutomationElement.ControlTypeProperty,
classic.ControlType.Window),
classic.Condition.FalseCondition);
} else {
conditionsSet =
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 (string windowTitle in data.Name) {
IUiEltCollection windowCollection =
rootElement.FindAll(data.Recurse ? classic.TreeScope.Descendants : classic.TreeScope.Children, conditionsSet);
var controlSearcherData =
new ControlSearcherData {
Name = windowTitle,
AutomationId = data.AutomationId,
Class = data.Class,
Value = string.Empty,
// 20141001
// ControlType = (new string[]{ "Window", "Pane", "Menu" })
ControlType = (new []{ "Window", "Pane", "Menu" })
};
windowCollectionByProperties =
ReturnOnlyRightElements(
windowCollection,
controlSearcherData,
false,
true);
try {
if (null != windowCollectionByProperties && 0 < windowCollectionByProperties.Count) {
foreach (IUiElement aeWndByTitle in windowCollectionByProperties
.Where(aeWndByTitle => aeWndByTitle != null && (int)aeWndByTitle.GetCurrent().ProcessId > 0))
{
resultCollection.Add(aeWndByTitle);
}
windowCollectionByProperties.Clear();
} else {
IUiElement tempElement = null;
// one more attempt using the FindWindow function
IntPtr wndHandle = NativeMethods.FindWindowByCaption(IntPtr.Zero, windowTitle);
// 20141001
// if (wndHandle != null && wndHandle != IntPtr.Zero) {
if (wndHandle != IntPtr.Zero) {
tempElement =
UiElement.FromHandle(wndHandle);
}
if (null == tempElement || (int) tempElement.GetCurrent().ProcessId <= 0) continue;
resultCollection.Add(tempElement);
}
}
catch {}
// 20140122
// AutomationFactory.DisposeChildKernel();
// 20140131
// if (null != windowCollectionByProperties && 0 < windowCollectionByProperties.Count) {
// foreach (IUiElement element in windowCollectionByProperties) {
// element.Dispose();
// }
//.........这里部分代码省略.........