예제 #1
0
        /// <summary>
        /// 获取角色文本
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public static string GetRoleText(this IAccessible target)
        {
            Console.WriteLine($"获取对象 {target.GetHashCode().ToString("X")} 角色...");
            StringBuilder role   = new StringBuilder();
            int           result = GetRoleText(target.accRole[0], role, 256);

            return(role.ToString());
        }
예제 #2
0
        /// <summary>
        /// 获取状态文本
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public static string GetStateText(this IAccessible target)
        {
            Console.WriteLine($"获取对象 {target.GetHashCode().ToString("X")} 状态...");
            StringBuilder state  = new StringBuilder();
            int           result = GetStateText(target.accState[0], state, 256);

            return(state.ToString());
        }
예제 #3
0
 /// <summary>
 /// 获取指定ID的子对象
 /// 获取倒数第二级的子对象时会返回 (int32)1 ???
 /// </summary>
 /// <param name="target"></param>
 /// <param name="ChildID">子对象的ID</param>
 /// <returns></returns>
 public static IAccessible GetChild(this IAccessible target, int ChildID)
 {
     Console.WriteLine($"获取对象 {target.GetHashCode().ToString("X")} 指定 ID= {ChildID} 的子对象...");
     try
     {
         IAccessible[] Children = new IAccessible[target.accChildCount];
         AccessibleChildren(target, ChildID, 1, Children, out int pcObtained);
         return(Children.FirstOrDefault());
     }
     catch { return(null); }
 }
예제 #4
0
 /// <summary>
 /// 获取子对象
 /// 获取倒数第二级的子对象时会返回 (int32)1 ???
 /// </summary>
 /// <param name="target"></param>
 /// <returns></returns>
 public static IAccessible[] GetChildren(this IAccessible target)
 {
     Console.WriteLine($"获取对象 {target.GetHashCode().ToString("X")} 的子对象集合...");
     try
     {
         IAccessible[] Children = new IAccessible[target.accChildCount];
         AccessibleChildren(target, 0, target.accChildCount, Children, out int pcObtained);
         return(Children);
     }
     catch { return(null); }
 }
예제 #5
0
        /// <summary>
        /// 根据层级数组检索子对象
        /// 获取倒数第二级的子对象时会返回 (int32)1 ???
        /// </summary>
        /// <param name="target">容器对象</param>
        /// <param name="layers">层级数组</param>
        /// <returns></returns>
        public static IAccessible GetAccessibleByLayers(this IAccessible target, int[] layers)
        {
            Console.WriteLine($"获取对象 {target.GetHashCode().ToString("X")} 指定层级 {string.Join(", ", layers)} 的对象...");
            IAccessible CurrentAccessible = target;

            foreach (int layer in layers)
            {
                CurrentAccessible = CurrentAccessible.GetChild(layer);
                if (CurrentAccessible == null)
                {
                    return(null);
                }
            }
            return(CurrentAccessible);
        }
 ///
 public override int GetHashCode()
 {
     return(childID ^ iacc.GetHashCode());
 }
예제 #7
0
 ///
 public override int GetHashCode()
 {
     return(ChildID ^ IAccessible.GetHashCode());
 }
예제 #8
0
 /// <summary>
 /// 检索对应于IAccess接口的特定实例的窗口句柄
 /// </summary>
 /// <param name="accessible"></param>
 /// <returns></returns>
 public static IntPtr GetWindowFromAccessible(IAccessible accessible)
 {
     Console.WriteLine($"从对象 {accessible.GetHashCode().ToString("X")} 获取句柄...");
     WindowFromAccessibleObject(accessible, out IntPtr Handle);
     return(Handle);
 }