Esempio n. 1
0
        private void WindowFinder_MouseMove(object sender, MouseEventArgs e)
        {
            if (!searching)
            {
                EndSearch();
            }

            // Grab the window from the screen location of the mouse.
            POINT  windowPoint = POINT.FromPoint(this.PointToScreen(new Point(e.X, e.Y)));
            IntPtr found       = WindowFromPoint(windowPoint);

            // we have a valid window handle
            if (found != IntPtr.Zero)
            {
                // give it another try, it might be a child window (disabled, hidden .. something else)
                // offset the point to be a client point of the active window
                if (ScreenToClient(found, ref windowPoint))
                {
                    // check if there is some hidden/disabled child window at this point
                    IntPtr childWindow = ChildWindowFromPoint(found, windowPoint);
                    if (childWindow != IntPtr.Zero)
                    {                           // great, we have the inner child
                        found = childWindow;
                    }
                }
            }

            // Is this the same window as the last detected one?
            if (found != window.HWND)
            {
                window.SetWindowHandle(found);
                //Trace.WriteLine ( "FoundWindow:" + window.Name + ":" + window.Text + " Managed:" + window.IsManaged );
            }
        }
        private void WindowFinder_MouseMove(object sender, MouseEventArgs e)
        {
            if (!_searching)
            {
                EndSearch();
            }

            // Grab the window from the screen location of the mouse.
            var windowPoint = POINT.FromPoint(PointToScreen(new Point(e.X, e.Y)));
            var found       = WindowFromPoint(windowPoint);

            // we have a valid window handle
            if (found != IntPtr.Zero)
            {
                if (ScreenToClient(found, ref windowPoint))
                {
                    // check if there is some hidden/disabled child window at this point
                    var childWindow = ChildWindowFromPoint(found, windowPoint);
                    if (childWindow != IntPtr.Zero)
                    {
                        found = childWindow;
                    }
                }
            }

            // Is this the same window as the last detected one?
            if (found != Window.DetectedWindow)
            {
                Window.SetWindowHandle(found);
                Trace.WriteLine("FoundWindow:" + Window.Name + ":" + Window.Text + " Managed:" + Window.IsManaged);
                InvokeActiveWindowChanged();
            }
        }
Esempio n. 3
0
        public static void FindMonitorRectsFromPoint(Point point, out Rect monitorRect, out Rect workAreaRect)
        {
            var absolutePosition = FindDisplayForAbsolutePosition(point);
            var monitorInfo      = new MonitorInfo();

            if (absolutePosition == -1)
            {
                GetMonitorInfo(User32.MonitorFromPoint(POINT.FromPoint(point), 2), ref monitorInfo);
            }
            else
            {
                monitorInfo = Displays[absolutePosition].MonitorInfo;
            }
            GetMonitorRects(monitorInfo, out monitorRect, out workAreaRect);
        }