예제 #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));
     }
 }
예제 #2
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();
     }
 }