Пример #1
0
        private void hwndText_TextChanged(object sender, TextChangedEventArgs e)
        {
            IntPtr hwnd;

            if (IsIntPtr(hwndText.Text, 16) && (hwnd = Hwnd) != IntPtr.Zero && WinUser.IsWindow(hwnd) && hwnd != Handle)
            {
                s_hButton.IsEnabled = true;
                s_hButton.IsChecked = WinUser.IsWindowVisible(hwnd);
                e_dButton.IsEnabled = true;
                e_dButton.IsChecked = WinUser.IsWindowEnabled(hwnd);

                gotoNextButton.IsEnabled = NextWindow(hwnd) != IntPtr.Zero ? true : false;
                gotoPrevButton.IsEnabled = PrevWindow(hwnd) != IntPtr.Zero ? true : false;
                AddHandle(hwnd);

                StringBuilder strb = new StringBuilder(256);
                WinUser.GetWindowText(hwnd, strb, 256);
                string title = strb.ToString();
                this.Title = string.Format("{0} - {1}", assemblyName.Name, title);
            }
            else
            {
                WhenNullHandle();
            }
        }
Пример #2
0
        void FillTree(IntPtr hwnd, TreeViewItem root)
        {
            TreeViewItem tvi = new TreeViewItem()
            {
                Header         = GetWindowToString(hwnd),
                HeaderTemplate = hwndtree.ItemTemplate,
                Tag            = WinUser.IsWindowVisible(hwnd),
            };

            if (root == null)
            {
                hwndtree.Items.Add(tvi);
            }
            else
            {
                root.Items.Add(tvi);
            }
            List <IntPtr> childs = new List <IntPtr>();

            FindWindow(hwnd, IntPtr.Zero, childs);
            foreach (var i in childs)
            {
                FillTree(i, tvi);
            }
        }
Пример #3
0
        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;
            }
        }
Пример #4
0
 private void ShowHideClick(object sender, RoutedEventArgs e)
 {
     WinUser.ShowWindow(Hwnd, WinUser.IsWindowVisible(Hwnd) == true ? 0 : 1);
     s_hButton.IsChecked = WinUser.IsWindowVisible(Hwnd);
 }