Exemplo n.º 1
0
        private static List <ControlHandle> GetFromProcess(Process process)
        {
            var resultWindowsList = new List <ControlHandle>();

            WindowsMethods.EnumWindows((hWnd, _) =>
            {
                ControlHandle control = hWnd;
                if (control.IsAppWindow())
                {
                    if (process.Id > 0)
                    {
                        var windowProcessId = 0;
                        WindowsMethods.GetWindowThreadProcessId(control, ref windowProcessId);
                        if (windowProcessId == process.Id)
                        {
                            resultWindowsList.Add(control);
                        }
                    }
                    else
                    {
                        resultWindowsList.Add(control);
                    }
                }
                return(true);
            }, 0);
            return(resultWindowsList);
        }
Exemplo n.º 2
0
        public IEnumerable <ControlHandle> GetChildrenWindows()
        {
            ControlHandle found = WindowsMethods.FindWindowEx(IntPtr.Zero, IntPtr.Zero, null, null);

            while (found.Equals(IntPtr.Zero) == false)
            {
                if (found.IsVisibleWindow() && found.GetParentOrOwner() == Handle)
                {
                    yield return(found);
                }
                found = WindowsMethods.FindWindowEx(IntPtr.Zero, found, null, null);
            }
        }
Exemplo n.º 3
0
 private bool Equals(ControlHandle wnd)
 {
     return(Handle == wnd.Handle && Class == wnd.Class && Title == wnd.Title);
 }