Beispiel #1
0
        public static AutomationWrapper FindWindowForProcessId(int id, string windowClassName, string name)
        {
            // Hmmm, try and find window for this process then.
            IntPtr hwnd = GetWindow(GetDesktopWindow(), GetWindowOptions.Child);

            while (hwnd != IntPtr.Zero)
            {
                int procid;
                int thread = GetWindowThreadProcessId(hwnd, out procid);
                if (procid == id)
                {
                    AutomationWrapper acc = AutomationWrapper.AccessibleObjectForWindow(hwnd);
                    if (acc != null && (windowClassName == null || acc.ClassName == windowClassName) &&
                        (name == null || acc.Name == name))
                    {
                        if (IsWindowVisible(hwnd))
                        {
                            return(acc);
                        }
                    }
                }
                hwnd = GetWindow(hwnd, GetWindowOptions.Next);
            }
            return(null);
        }
Beispiel #2
0
 public Window(Window parent, IntPtr handle)
 {
     this.parent = parent;
     this.handle = handle;
     this.acc    = AutomationWrapper.AccessibleObjectForWindow(handle);
 }