private void GoToWindow(IntPtr owner, GoToNavigation gotoNav) { var hwnd = owner; switch (gotoNav) { case GoToNavigation.Next: hwnd = NextWindow(owner); break; case GoToNavigation.Previous: hwnd = PrevWindow(owner); break; case GoToNavigation.Ancestor: hwnd = WinUser.GetAncestor(owner, 1); break; case GoToNavigation.Child: hwnd = WinUser.FindWindowEx(owner, IntPtr.Zero, null, null); break; } if (hwnd != IntPtr.Zero) { hwndText.Text = hwnd.ToString("X8"); } var item = GetWindowToString(hwnd); hwndlist.SelectedItem = item; hwndlist.BringIntoView(); }
private void FindWindow(IntPtr parent, IntPtr prev, List <IntPtr> list) { var child = WinUser.FindWindowEx(parent, prev, null, null); if (child == IntPtr.Zero) { return; } list.Add(child); FindWindow(parent, child, list); }
private IntPtr NextWindow(IntPtr owner) { return(WinUser.FindWindowEx(WinUser.GetAncestor(owner, 1), owner, null, null)); }