public static XAccessible GetAccessibleChildDescriptionStartsWith(String descriptionStart, XAccessibleContext haystack) { try { if (haystack != null && !String.IsNullOrWhiteSpace(descriptionStart)) { string desc = GetAccessibleDesc(haystack); if (desc != null && desc.StartsWith(descriptionStart)) { return haystack as XAccessible; } if (haystack.getAccessibleChildCount() > 0) { int childCount = haystack.getAccessibleChildCount(); for (int i = 0; i < childCount; i++) { var c = haystack.getAccessibleChild(i); if (c != null) { if (c.Equals(haystack)) continue; var child = GetAccessibleChildDescriptionStartsWith(descriptionStart, c.getAccessibleContext()); if (child != null) return child; } } } } } catch { } return null; }
/// <summary> /// Gets the name of the accessible child with. /// </summary> /// <param name="name">The name.</param> /// <param name="haystack">The haystack.</param> /// <returns>The first found XAccessible with a partly equal name or NULL</returns> public static XAccessible GetAccessibleChildWithName(String name, XAccessibleContext haystack) { try { if (haystack != null && !String.IsNullOrWhiteSpace(name)) { if (GetAccessibleName(haystack).Equals(name)) { return haystack as XAccessible; } if (haystack.getAccessibleChildCount() > 0) { int childCount = haystack.getAccessibleChildCount(); for (int i = 0; i < childCount; i++) { var c = haystack.getAccessibleChild(i); if (c != null) { if (c.Equals(haystack)) continue; var child = GetAccessibleChildWithName(name, c); if (child != null) return child; } } } } } catch { } return null; }