public static bool IsVirtualizedItemPatternAvailable(this AutomationElement element) { if (element is null) { throw new System.ArgumentNullException(nameof(element)); } return((bool)element.GetCurrentPropertyValue(AutomationElementIdentifiers.IsVirtualizedItemPatternAvailableProperty)); }
public static string LocalizedControlType(this AutomationElement element) { if (element is null) { throw new System.ArgumentNullException(nameof(element)); } return((string)element.GetCurrentPropertyValue(AutomationElementIdentifiers.LocalizedControlTypeProperty)); }
public static object LabeledBy(this AutomationElement element) { if (element is null) { throw new System.ArgumentNullException(nameof(element)); } return(element.GetCurrentPropertyValue(AutomationElementIdentifiers.LabeledByProperty)); }
public static OrientationType Orientation(this AutomationElement element) { if (element is null) { throw new System.ArgumentNullException(nameof(element)); } return((OrientationType)element.GetCurrentPropertyValue(AutomationElementIdentifiers.OrientationProperty)); }
public static int NativeWindowHandle(this AutomationElement element) { if (element is null) { throw new System.ArgumentNullException(nameof(element)); } return((int)element.GetCurrentPropertyValue(AutomationElementIdentifiers.NativeWindowHandleProperty)); }
public static System.Windows.Point ClickablePoint(this AutomationElement element) { if (element is null) { throw new System.ArgumentNullException(nameof(element)); } return((System.Windows.Point)element.GetCurrentPropertyValue(AutomationElementIdentifiers.ClickablePointProperty)); }
public static int[] RuntimeId(this AutomationElement element) { if (element is null) { throw new System.ArgumentNullException(nameof(element)); } return((int[])element.GetCurrentPropertyValue(AutomationElementIdentifiers.RuntimeIdProperty)); }
public static CultureInfo Culture(this AutomationElement element) { if (element is null) { throw new System.ArgumentNullException(nameof(element)); } return((CultureInfo)element.GetCurrentPropertyValue(AutomationElementIdentifiers.CultureProperty)); }
public static string FrameworkId(this AutomationElement element) { if (element is null) { throw new System.ArgumentNullException(nameof(element)); } return((string)element.GetCurrentPropertyValue(AutomationElementIdentifiers.FrameworkIdProperty)); }
public static bool HasKeyboardFocus(this AutomationElement element) { if (element is null) { throw new System.ArgumentNullException(nameof(element)); } return((bool)element.GetCurrentPropertyValue(AutomationElementIdentifiers.HasKeyboardFocusProperty)); }
public static System.Windows.Rect BoundingRectangle(this AutomationElement element) { if (element is null) { throw new System.ArgumentNullException(nameof(element)); } return((System.Windows.Rect)element.GetCurrentPropertyValue(AutomationElementIdentifiers.BoundingRectangleProperty)); }
public static bool IsRequiredForForm(this AutomationElement element) { if (element is null) { throw new System.ArgumentNullException(nameof(element)); } return((bool)element.GetCurrentPropertyValue(AutomationElementIdentifiers.IsRequiredForFormProperty)); }
internal static bool IsMatch(AutomationElement element, Condition condition) { switch (condition) { case PropertyCondition propertyCondition: { var value = element.GetCurrentPropertyValue(propertyCondition.Property); if (Equals(propertyCondition.Property, AutomationElement.ControlTypeProperty) && value is ControlType controlType && propertyCondition.Value is int id) { return(controlType.Id == id); } switch (propertyCondition.Flags) { case PropertyConditionFlags.None: return(Equals(value, propertyCondition.Value)); case PropertyConditionFlags.IgnoreCase: return(string.Equals((string)value, (string)propertyCondition.Value, StringComparison.OrdinalIgnoreCase)); default: throw new ArgumentOutOfRangeException(); } } case AndCondition andCondition: return(andCondition.GetConditions().All(c => IsMatch(element, c))); case OrCondition orCondition: return(orCondition.GetConditions().Any(c => IsMatch(element, c))); case NotCondition notCondition: return(!IsMatch(element, notCondition.Condition)); case var c when c == Condition.TrueCondition: return(true); case var c when c == Condition.FalseCondition: return(false); default: throw new ArgumentOutOfRangeException(nameof(condition), condition, "Condition not suported"); } }
internal static bool IsMatch(AutomationElement element, Condition condition) { switch (condition) { case PropertyCondition propertyCondition: { var value = element.GetCurrentPropertyValue(propertyCondition.Property); if (Equals(propertyCondition.Property, AutomationElement.ControlTypeProperty) && value is ControlType controlType && propertyCondition.Value is int id) { return(controlType.Id == id); } return(propertyCondition.Flags switch { PropertyConditionFlags.None => Equals(value, propertyCondition.Value), PropertyConditionFlags.IgnoreCase => string.Equals((string)value, (string)propertyCondition.Value, StringComparison.OrdinalIgnoreCase), _ => throw new ArgumentOutOfRangeException(nameof(condition), propertyCondition.Flags, "Unknown flags."), }); }
private static void PropertiesAndPatterns(AutomationElement element, IndentedTextWriter writer, bool all = true) { if (all) { foreach (var pattern in element.GetSupportedPatterns()) { writer.WriteLine(pattern.ProgrammaticName); writer.Indent++; var currentPattern = element.GetCurrentPattern(pattern); writer.WriteLine(currentPattern); if (currentPattern.GetType().GetProperty("Current") is { } currentProperty&& currentProperty.GetValue(currentPattern) is { } value) { foreach (var property in value.GetType().GetProperties()) { writer.WriteLine($"{property.Name} {property.GetValue(value) ?? "null"}"); } } writer.Indent--; } foreach (var property in element.GetSupportedProperties().OrderBy(x => x.ProgrammaticName)) { writer.WriteLine($"{property.ProgrammaticName.TrimStart("AutomationElementIdentifiers.").TrimEnd("Property")} {element.GetCurrentPropertyValue(property) ?? "null"}"); } writer.WriteLine(); } else { var info = element.Current; writer.WriteLine($"ControlType: {info.ControlType.ProgrammaticName} (LocalizedControlType: {info.LocalizedControlType})"); writer.WriteLine($"ClassName: {info.ClassName}"); writer.WriteLine($"Name: {info.Name}"); writer.WriteLine($"AutomationId: {info.AutomationId}"); writer.WriteLine($"IsContentElement: {info.IsContentElement} IsControlElement: {info.IsControlElement}"); writer.WriteLine($"Properties: {string.Join(", ", element.GetSupportedProperties().Select(x => x.ProgrammaticName.TrimStart("AutomationElementIdentifiers.").TrimEnd("Property")).OrderBy(x => x))}"); writer.WriteLine($"Patterns: {string.Join(", ", element.GetSupportedPatterns().Select(x => x.ProgrammaticName.TrimEnd("Identifiers.Pattern").TrimEnd("Pattern")).OrderBy(x => x))}"); writer.WriteLine(); } }
public static bool IsOffscreen(this AutomationElement element) => (bool)element.GetCurrentPropertyValue(AutomationElementIdentifiers.IsOffscreenProperty);
public static bool IsPassword(this AutomationElement element) => (bool)element.GetCurrentPropertyValue(AutomationElementIdentifiers.IsPasswordProperty);
public static bool IsRequiredForForm(this AutomationElement element) => (bool)element.GetCurrentPropertyValue(AutomationElementIdentifiers.IsRequiredForFormProperty);
public static bool IsSynchronizedInputPatternAvailable(this AutomationElement element) => (bool)element.GetCurrentPropertyValue(AutomationElementIdentifiers.IsSynchronizedInputPatternAvailableProperty);
public static bool IsVirtualizedItemPatternAvailable(this AutomationElement element) => (bool)element.GetCurrentPropertyValue(AutomationElementIdentifiers.IsVirtualizedItemPatternAvailableProperty);
public static int ProcessId(this AutomationElement element) => (int)element.GetCurrentPropertyValue(AutomationElementIdentifiers.ProcessIdProperty);
public static object LabeledBy(this AutomationElement element) => element.GetCurrentPropertyValue(AutomationElementIdentifiers.LabeledByProperty);
public static string AccessKey(this AutomationElement element) => (string)element.GetCurrentPropertyValue(AutomationElementIdentifiers.AccessKeyProperty);
public static string LocalizedControlType(this AutomationElement element) => (string)element.GetCurrentPropertyValue(AutomationElementIdentifiers.LocalizedControlTypeProperty);
public static string Name(this AutomationElement element) => (string)element.GetCurrentPropertyValue(AutomationElementIdentifiers.NameProperty);
public static int NativeWindowHandle(this AutomationElement element) => (int)element.GetCurrentPropertyValue(AutomationElementIdentifiers.NativeWindowHandleProperty);
public static bool IsMultipleViewPatternAvailable(this AutomationElement element) => (bool)element.GetCurrentPropertyValue(AutomationElementIdentifiers.IsMultipleViewPatternAvailableProperty);
public static string ItemStatus(this AutomationElement element) => (string)element.GetCurrentPropertyValue(AutomationElementIdentifiers.ItemStatusProperty);
public static bool IsKeyboardFocusable(this AutomationElement element) => (bool)element.GetCurrentPropertyValue(AutomationElementIdentifiers.IsKeyboardFocusableProperty);
public static OrientationType Orientation(this AutomationElement element) => (OrientationType)element.GetCurrentPropertyValue(AutomationElementIdentifiers.OrientationProperty);