Ejemplo n.º 1
0
        /// <summary>
        /// 获取窗体内容
        /// </summary>
        /// <param name="hander"></param>
        /// <returns></returns>
        private string GetText(IntPtr hander)
        {
            StringBuilder sb = new StringBuilder(255);

            WinApi.GetWindowTextW(hander, sb, 255);
            return(sb.ToString());
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取子控件句柄
 /// </summary>
 /// <param name="handle"></param>
 /// <returns></returns>
 public static List<WindowInfo> EnumChildWindowsCallback(IntPtr handle)
 {
     List<WindowInfo> wndList = new List<WindowInfo>();
     WinApi.EnumChildWindows(handle, delegate (IntPtr hWnd, int lParam)
     {
         WindowInfo wnd = new WindowInfo();
         StringBuilder sb = new StringBuilder(256);
         wnd.hWnd = hWnd;
         WinApi.GetWindowTextW(hWnd, sb, sb.Capacity);
         wnd.szWindowName = sb.ToString();
         WinApi.GetClassName(hWnd, sb, sb.Capacity);
         wnd.szClassName = sb.ToString();
         wnd.parentHWnd = WinApi.GetParent(hWnd);
         wnd.id = (int)hWnd;
         wndList.Add(wnd);
         return true;
     }, 0);
     return wndList;
 }