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 IntPtr PrevWindow(IntPtr owner) { var list = GetChildsWindows(WinUser.GetAncestor(owner, 1)); int indx = list.IndexOf(owner); if (indx > 0) { return(list[indx - 1]); } return(IntPtr.Zero); }
private void search_PreviewMouseMove(object sender, MouseEventArgs e) { if (isSearching) { var p = GlobalMouse.Position; last_p = p; IntPtr _hwnd = WinUser.WindowFromPoint(new MS.Interop.WinUser.POINT() { x = (int)p.X, y = (int)p.Y }); if (GetControlText(_hwnd).Contains("SVG Code")) { int t = 1; } if (WinUser.GetAncestor(_hwnd, 1) != DesktopHandle) { var next = NextWindow(_hwnd); while (next != IntPtr.Zero && WinUser.IsWindowVisible(next)) { WinUser.Rect _rect; WinUser.GetWindowRect(next, out _rect); if (p.X >= _rect.Left && p.X <= _rect.Right && p.Y >= _rect.Top && p.Y <= _rect.Bottom) { _hwnd = next; } next = NextWindow(next); } } WinUser.Rect rect; WinUser.GetWindowRect(_hwnd, out rect); int width = rect.Right - rect.Left; int height = rect.Bottom - rect.Top; int x_rel = (int)(p.X - rect.Left); int y_rel = (int)(p.Y - rect.Top); if (last_hwnd == _hwnd || _hwnd == wmHandle || _hwnd == cpHandle) { return; } last_hwnd = _hwnd; status.Text = string.Format("({0}, {1})-({2}, {3}) {4}x{5}", rect.Left, rect.Top, rect.Right, rect.Bottom, rect.Right - rect.Left, rect.Bottom - rect.Top); wm.Left = rect.Left; wm.Top = rect.Top; wm.Width = rect.Right - rect.Left; wm.Height = rect.Bottom - rect.Top; if (WinUser.IsMaximize(_hwnd)) { wm.Left = 0; wm.Top = 0; wm.Width = rect.Right + rect.Left; wm.Height = rect.Bottom + rect.Top; } string str_hwnd = Convert.ToString(_hwnd.ToInt32(), 16).ToUpper(); while (str_hwnd.Length < 8) { str_hwnd = "0" + str_hwnd; } this.hwndText.Text = str_hwnd; } }
private IntPtr NextWindow(IntPtr owner) { return(WinUser.FindWindowEx(WinUser.GetAncestor(owner, 1), owner, null, null)); }