Ejemplo n.º 1
0
 private SelectableTreeNodeData SelectFromPoint(int lastX, int lastY)
 {
     if (selAccObjs.Checked)
     {
         SystemAccessibleObject sao = SystemAccessibleObject.FromPoint(lastX, lastY);
         return(new AccessibilityData(this, sao));
     }
     else
     {
         SystemWindow sw = SystemWindow.FromPointEx(lastX, lastY, selToplevel.Checked, false);
         if (!heuristicSearch.Checked && !selToplevel.Checked)
         {
             sw = SystemWindow.FromPoint(lastX, lastY);
         }
         if (sw != highlightedWindow)
         {
             if (highlightedWindow != null)
             {
                 highlightedWindow.Refresh();
                 highlightedWindow = null;
             }
             if (sw.HWnd != this.Handle && !sw.IsDescendantOf(new SystemWindow(this.Handle)))
             {
                 sw.Highlight();
                 highlightedWindow = sw;
             }
         }
         return(new WindowData(this, sw));
     }
 }
Ejemplo n.º 2
0
        public ApiResult GetContent(IntPtr hwnd)
        {
            Rectangle     rect    = Interop.GetWindowRect(hwnd);
            SystemWindow  w       = SystemWindow.FromPoint(rect.X, rect.Y);
            WindowContent content = w.Content;

            return(ApiResult.Unknown);
        }
Ejemplo n.º 3
0
        public static IntPtr GetWindowFromPoint(Point position)
        {
            SystemWindow window = SystemWindow.FromPoint((int)(position.X + 0.5), (int)(position.Y + 0.5));

            if (window == null)
            {
                return(InvalidWindow);
            }
            return(window.HWnd);
        }
Ejemplo n.º 4
0
#pragma warning restore CS0618

        private bool IsFullScreenWindow(Point targetPoint)
        {
            SystemWindow deskWindow = SystemWindow.DesktopWindow;

            SystemWindow sw = SystemWindow.FromPoint(targetPoint.X, targetPoint.Y);

            if (sw == null)
            {
                return(false);
            }

            // get the window with the largest area
            RECT rect = sw.Rectangle;
            int  area = rect.Height * rect.Width;

            while (sw.ParentSymmetric != null)
            {
                sw = sw.ParentSymmetric;
                RECT parentRect = sw.Rectangle;
                int  parentArea = parentRect.Height * parentRect.Width;
                if (parentArea > area)
                {
                    area = parentArea;
                    rect = parentRect;
                }
            }

            if (sw.HWnd == IntPtr.Zero || sw == deskWindow || sw == SystemWindow.ShellWindow)
            {
                return(false);
            }

            var desktopRect = deskWindow.Rectangle;

            if (rect.Left == desktopRect.Left && rect.Top == desktopRect.Top && rect.Right == desktopRect.Right && rect.Bottom == desktopRect.Bottom)
            {
                switch (sw.ClassName)
                {
                case "WorkerW":
                case "Progman":
                case "CanvasWindow":
                case "ImmersiveLauncher":
                    return(false);

                default:
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
 private void mouseHook_MouseDown(object sender, MouseEventArgs e)
 {
     if (highlightedWindow == null || shouldClose)
     {
         return;
     }
     if (e.Button == MouseButtons.Right)
     {
         rightButtonDown = true;
         if (extraPointIndex != -1)
         {
             extraPointIndex = -1;
             UpdateLabel();
         }
         else if (highlightedObject != null)
         {
             SystemAccessibleObject acc = highlightedObject.Parent;
             if (acc.Window == highlightedWindow)
             {
                 Highlight(highlightedWindow, acc);
             }
             else
             {
                 Highlight(highlightedWindow, null);
             }
         }
         else
         {
             if (freshWindow)
             {
                 Point        pt = Cursor.Position;
                 SystemWindow sw = SystemWindow.FromPoint(pt.X, pt.Y);
                 if (highlightedWindow.IsDescendantOf(sw))
                 {
                     sw = highlightedWindow;
                 }
                 if (sw == highlightedWindow)
                 {
                     sw = sw.ParentSymmetric;
                 }
                 Highlight(sw, null);
                 freshWindow = false;
             }
             else
             {
                 Highlight(highlightedWindow.ParentSymmetric, null);
             }
         }
     }
     else if (e.Button == MouseButtons.Left)
     {
         if (extraPointIndex != -1)
         {
             extraPoints[extraPointIndex] = Cursor.Position;
         }
         if (rightButtonDown && accessibleObjectSelectName != null)
         {
             selectAccObjects = !selectAccObjects;
         }
         else if (extraPointIndex != extraPoints.Length - 1)
         {
             extraPointIndex++;
         }
         else
         {
             shouldClose = true;
         }
         UpdateLabel();
     }
 }