///
 public bool Equals(SystemAccessibleObject sao)
 {
     if ((object)sao == null)
     {
         return(false);
     }
     return(childID == sao.childID && DeepEquals(iacc, sao.iacc));
 }
Exemple #2
0
 ///
 public bool Equals(SystemAccessibleObject sao)
 {
     if ((object)sao == null)
     {
         return(false);
     }
     return(ChildID == sao.ChildID && DeepEquals(IAccessible, sao.IAccessible));
 }
        ///
        public override bool Equals(System.Object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            SystemAccessibleObject sao = obj as SystemAccessibleObject;

            return(Equals(sao));
        }
Exemple #4
0
 private void AddIfChildren(SystemAccessibleObject o, TreeNode tn)
 {
     try
     {
         if (o.Children.Length > 0)
         {
             tn.Nodes.Add(new TreeNode("(loading)"));
         }
     }
     catch (COMException) { }
 }
Exemple #5
0
 private void collectValues(StringBuilder sb, SystemAccessibleObject sao)
 {
     try
     {
         sb.AppendLine(sao.Value);
     }
     catch (COMException) { }
     try
     {
         SystemAccessibleObject[] children = sao.Children;
         foreach (SystemAccessibleObject c in children)
         {
             collectValues(sb, c);
         }
     }
     catch (COMException) { }
 }
Exemple #6
0
 private void Highlight(SystemWindow sw, SystemAccessibleObject acc)
 {
     if (sw == null) return;
     if (acc != null && acc != highlightedObject)
     {
         if (highlightedWindow != null)
             highlightedWindow.Refresh();
         acc.Highlight();
     }
     else if (sw != highlightedWindow)
     {
         if (highlightedWindow != null)
             highlightedWindow.Refresh();
         sw.Highlight();
     }
     highlightedObject = acc;
     highlightedWindow = sw;
 }
Exemple #7
0
 private void selCrosshair_CrosshairDragged(object sender, EventArgs e)
 {
     selCrosshair_CrosshairDragging(sender, e);
     if (highlightedObject != null)
     {
         highlightedObject.Window.Refresh();
         highlightedObject = null;
     }
     LoadTree(lastObject);
     tree.Enabled = true;
 }
 void scrollingSelection_SelectionFinished(Point pt, SystemWindow sw, SystemAccessibleObject accObj, Point[] extraPoints)
 {
     if (autodetectScrollOption.Checked)
     {
         Rectangle position = sw.Position;
         Bitmap bmp = Screenshot.TakeOverlargeScreenshot(sw, false);
         if (bmp.Width == position.Width + 1 && bmp.Height == position.Height + 1)
         {
             bmp = Screenshot.TakeOverlargeScreenshot(sw, true);
         }
         if (bmp.Width == position.Width + 1 && bmp.Height == position.Height + 1)
         {
             bmp = Screenshot.TakeVerticalScrollingScreenshot(pt, sw, null);
         }
         if (bmp.Width == position.Width && bmp.Height == position.Height)
         {
             KeyboardKey.InjectMouseEvent(0x0800, 0, 0, 120, UIntPtr.Zero);
             Application.DoEvents();
             Thread.Sleep(500);
             Application.DoEvents();
             bmp = Screenshot.TakeHorizontalScrollingScreenshot(pt, sw, null);
         }
         if (bmp.Width == position.Width && bmp.Height == position.Height)
         {
             KeyboardKey.InjectMouseEvent(0x0800, 0, 0, 120, UIntPtr.Zero);
             MessageBox.Show("Unable to create scrolling capture. You might want to try one of the manual options.");
         }
         else
         {
             HandleScreenshot(bmp);
         }
     }
     else if (wmPrintScrollOption.Checked)
     {
         HandleScreenshot(Screenshot.TakeOverlargeScreenshot(sw, false));
     }
     else if (wmPrintClientScrollOption.Checked)
     {
         HandleScreenshot(Screenshot.TakeOverlargeScreenshot(sw, true));
     }
     else if (vWheelScrollOption.Checked)
     {
         HandleScreenshot(Screenshot.TakeVerticalScrollingScreenshot(pt, sw, null));
     }
     else if (hWheelScrollOption.Checked)
     {
         HandleScreenshot(Screenshot.TakeHorizontalScrollingScreenshot(pt, sw, null));
     }
     else if (vBarScrollOption.Checked)
     {
         HandleScreenshot(Screenshot.TakeVerticalScrollingScreenshot(pt, sw, extraPoints[0]));
     }
     else if (hBarScrollOption.Checked)
     {
         HandleScreenshot(Screenshot.TakeHorizontalScrollingScreenshot(pt, sw, extraPoints[0]));
     }
 }
Exemple #9
0
        private void LoadProperties(SystemAccessibleObject sao)
        {
            if (sao == null)
            {
                propChildID.Text = "";
                propDefaultAction.Text = "(none)";
                propDescription.Text = "";
                propLocation.Text = "";
                propName.Text = "(no object selected)";
                propRole.Text = "";
                propState.Text = "";
                propValue.Text = "";
                propWindow.Text = "";
                propLocation.Enabled = propDefaultAction.Enabled = false;
            }
            else
            {
                propChildID.Text = "" + sao.ChildID;
                propLocation.Enabled = propDefaultAction.Enabled = true;

                // sao.Children not used

                try { propDefaultAction.Text = sao.DefaultAction; }
                catch (COMException) { propDefaultAction.Text = "??"; }

                try
                {
                    propDefaultAction.Text += " [" + sao.KeyboardShortcut + "]";
                }
                catch (COMException) { }

                try { propDescription.Text = sao.Description; }
                catch (COMException) { propDescription.Text = "??"; }

                // sao.IAccessible not used

                try
                {
                    Rectangle location = sao.Location;
                    propLocation.Text = "(" + location.X + "," + location.Y + ")+(" + location.Width + "x" + location.Height + ")";
                }
                catch (COMException)
                {
                    propLocation.Text = "??";
                    propLocation.Enabled = false;
                }

                try { propName.Text = sao.Name; }
                catch (COMException) { propName.Text = "??"; }

                // sao.Parent not used

                try {
                    int r = sao.RoleIndex;
                    propRole.Text = (r == -1 ? "" : "["+r+"] ")+sao.RoleString; }
                catch (COMException) { propRole.Text = "??"; }

                // sao.SelectedObjects not used

                try { propState.Text = "[0x"+sao.State.ToString("x")+"] "+sao.StateString; }
                catch (COMException) { propState.Text = "??"; }

                try
                {
                    if (includeChildren.Checked)
                    {
                        StringBuilder sb = new StringBuilder();
                        collectValues(sb, sao);
                        propValue.Text = sb.ToString();
                    }
                    else
                    {
                        propValue.Text = sao.Value;
                    }
                }
                catch (COMException ex)
                {
                    propValue.Text = "?? " + ex.ToString();
                }

                try { propWindow.Text = "[0x"+sao.Window.HWnd.ToString("x")+"] "+sao.Window.Title; }
                catch (COMException) { propWindow.Text = "??"; }
            }
            lastObject = sao;
        }
Exemple #10
0
 private void LoadAll(SystemAccessibleObject sao)
 {
     LoadProperties(sao);
     LoadTree(sao);
     tree.Enabled = true;
 }
 private void objectSelection_SelectionFinished(Point pt, SystemWindow sw, SystemAccessibleObject accObj, Point[] extraPoints)
 {
     if (accObj != null)
         HandleScreenshot(Screenshot.TakeScreenshot(accObj, false, shapeOption.Checked));
     else
         HandleScreenshot(Screenshot.TakeScreenshot(sw, false, false, shapeOption.Checked));
 }
 private void ParseClientAreaElement(StringBuilder sb, SystemAccessibleObject sao, int depth)
 {
     sb.Append("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
     sb.Append(ListContent.Repeat('*', depth) + " " + sao.ToString() + "\n");
     try
     {
         sb.Append("D: " + sao.Description + "\n");
     }
     catch (COMException) { }
     try
     {
         sb.Append("V: " + sao.Value + "\n");
     }
     catch (COMException) { }
     foreach (SystemAccessibleObject c in sao.Children)
     {
         if (c.Window == sao.Window)
             ParseClientAreaElement(sb, c, depth + 1);
     }
 }
 private static bool DeepEquals(IAccessible ia1, IAccessible ia2)
 {
     if (ia1.Equals(ia2)) return true;
     if (Marshal.GetIUnknownForObject(ia1) == Marshal.GetIUnknownForObject(ia2)) return true;
     try
     {
         if (ia1.accChildCount != ia2.accChildCount) return false;
         SystemAccessibleObject sa1 = new SystemAccessibleObject(ia1, 0);
         SystemAccessibleObject sa2 = new SystemAccessibleObject(ia2, 0);
         if (sa1.Window.HWnd != sa2.Window.HWnd) return false;
         if (sa1.Location != sa2.Location) return false;
         if (sa1.DefaultAction != sa2.DefaultAction) return false;
         if (sa1.Description != sa2.Description) return false;
         if (sa1.KeyboardShortcut != sa2.KeyboardShortcut) return false;
         if (sa1.Name != sa2.Name) return false;
         if (!sa1.Role.Equals(sa2.Role)) return false;
         if (sa1.State != sa2.State) return false;
         if (sa1.Value != sa2.Value) return false;
         if (sa1.Visible != sa2.Visible) return false;
         if (ia1.accParent == null && ia2.accParent == null) return true;
         if (ia1.accParent == null || ia2.accParent == null) return false;
     }
     catch (COMException)
     {
         return false;
     }
     bool de = DeepEquals((IAccessible)ia1.accParent, (IAccessible)ia2.accParent);
     return de;
 }
Exemple #14
0
 private void LoadTree(SystemAccessibleObject sao)
 {
     tree.Nodes.Clear();
     if (sao == null) return;
     IntPtr hwnd = sao.Window.HWnd;
     List<SystemAccessibleObject> parents = new List<SystemAccessibleObject>();
     parents.Add(sao);
     while (true)
     {
         sao = sao.Parent;
         if (sao == null) break;
         if (!allParents.Checked && sao.Window.HWnd != hwnd) break;
         parents.Add(sao);
     }
     sao = parents[parents.Count-1];
     parents.RemoveAt(parents.Count - 1);
     TreeNode curr = new TreeNode(sao.ToString());
     curr.Tag = sao;
     tree.Nodes.Add(curr);
     LoadTreeChildren(curr);
     while (parents.Count > 0)
     {
         sao = parents[parents.Count - 1];
         parents.RemoveAt(parents.Count - 1);
         TreeNode newcurr = null;
         foreach (TreeNode sub in curr.Nodes)
         {
             if ((SystemAccessibleObject)sub.Tag == sao)
             {
                 newcurr = sub;
                 break;
             }
         }
         if (newcurr == null)
         {
             foreach (TreeNode sub in curr.Nodes)
             {
                 if (sao.Equals((SystemAccessibleObject)sub.Tag))
                 {
                     newcurr = sub;
                     break;
                 }
             }
         }
         if (newcurr == null)
         {
             newcurr = new TreeNode("!! " + sao.ToString());
             newcurr.Tag = sao;
             curr.Nodes.Add(newcurr);
         }
         curr = newcurr;
         LoadTreeChildren(curr);
     }
     tree.SelectedNode = curr;
 }
Exemple #15
0
 private SelectableTreeNodeData SelectFromPoint(int lastX, int lastY)
 {
     if (selAccObjs.Checked)
     {
         SystemAccessibleObject sao = SystemAccessibleObject.FromPoint(lastX, lastY);
         if (sao != highlightedAccessibleObject)
         {
             if (highlightedWindow != null)
             {
                 highlightedWindow.Refresh();
                 highlightedWindow = null;
                 highlightedAccessibleObject = null;
             }
             SystemWindow sw = sao.Window;
             if (sw.HWnd != this.Handle && !sw.IsDescendantOf(new SystemWindow(this.Handle)))
             {
                 sao.Highlight();
                 highlightedWindow = sw;
                 highlightedAccessibleObject = sao;
             }
         }
         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;
                 highlightedAccessibleObject = null;
             }
             if (sw.HWnd != this.Handle && !sw.IsDescendantOf(new SystemWindow(this.Handle)))
             {
                 sw.Highlight();
                 highlightedWindow = sw;
             }
         }
         return new WindowData(this, sw);
     }
 }
Exemple #16
0
 private void crossHair_CrosshairDragged(object sender, EventArgs e)
 {
     this.Cursor = Cursors.WaitCursor;
     lastX = MousePosition.X;
     lastY = MousePosition.Y;
     UpdateSelection(true, false);
     if (highlightedWindow != null)
     {
         highlightedWindow.Refresh();
         highlightedWindow = null;
         highlightedAccessibleObject = null;
     }
     this.Cursor = null;
 }
Exemple #17
0
 /// <summary>
 /// Take a screenshot of a given accessible object
 /// </summary>
 /// <param name="accessibleObject">Accessible object to take the screenshot from.</param>
 /// <param name="includeCursor">Whether to include the mouse cursor.</param>
 /// <param name="keepShape">Whether to keep the shape (transparency region) of the window.</param>
 public static Bitmap TakeScreenshot(SystemAccessibleObject accessibleObject, bool includeCursor, bool keepShape)
 {
     Region shape = null;
     if (keepShape)
     {
         shape = accessibleObject.Window.Region;
         shape.Translate(accessibleObject.Window.Rectangle.Left - accessibleObject.Location.Left, accessibleObject.Window.Rectangle.Top - accessibleObject.Location.Top);
     }
     return TakeScreenshot(accessibleObject.Location, includeCursor, shape);
 }
        private static bool DeepEquals(IAccessible ia1, IAccessible ia2)
        {
            if (ia1.Equals(ia2))
            {
                return(true);
            }
            if (Marshal.GetIUnknownForObject(ia1) == Marshal.GetIUnknownForObject(ia2))
            {
                return(true);
            }
            if (ia1.accChildCount != ia2.accChildCount)
            {
                return(false);
            }
            SystemAccessibleObject sa1 = new SystemAccessibleObject(ia1, 0);
            SystemAccessibleObject sa2 = new SystemAccessibleObject(ia2, 0);

            if (sa1.Window.HWnd != sa2.Window.HWnd)
            {
                return(false);
            }
            if (sa1.Location != sa2.Location)
            {
                return(false);
            }
            if (sa1.DefaultAction != sa2.DefaultAction)
            {
                return(false);
            }
            if (sa1.Description != sa2.Description)
            {
                return(false);
            }
            if (sa1.KeyboardShortcut != sa2.KeyboardShortcut)
            {
                return(false);
            }
            if (sa1.Name != sa2.Name)
            {
                return(false);
            }
            if (!sa1.Role.Equals(sa2.Role))
            {
                return(false);
            }
            if (sa1.State != sa2.State)
            {
                return(false);
            }
            if (sa1.Value != sa2.Value)
            {
                return(false);
            }
            if (sa1.Visible != sa2.Visible)
            {
                return(false);
            }
            if (ia1.accParent == null && ia2.accParent == null)
            {
                return(true);
            }
            if (ia1.accParent == null || ia2.accParent == null)
            {
                return(false);
            }
            bool de = DeepEquals((IAccessible)ia1.accParent, (IAccessible)ia2.accParent);

            return(de);
        }
Exemple #19
0
 private void selCrosshair_CrosshairDragging(object sender, EventArgs e)
 {
     SystemAccessibleObject sao = SystemAccessibleObject.FromPoint(MousePosition.X, MousePosition.Y);
     if (highlightedObject == null || !highlightedObject.Equals(sao))
     {
         if (highlightedObject != null)
         {
             highlightedObject.Window.Refresh();
             highlightedObject = null;
         }
         sao.Highlight();
         highlightedObject = sao;
     }
     LoadProperties(sao);
     tree.Enabled = false;
 }
 ///
 public bool Equals(SystemAccessibleObject sao)
 {
     if ((object)sao == null)
     {
         return false;
     }
     return childID == sao.childID && DeepEquals(iacc, sao.iacc);
 }
Exemple #21
0
 public void SetSelectedObject(SystemAccessibleObject sao)
 {
     LoadProperties(sao);
     LoadTree(sao);
 }
 private void ParseSubMenu(StringBuilder menuitems, SystemAccessibleObject sao, int depth)
 {
     foreach (SystemAccessibleObject c in sao.Children)
     {
         if (c.RoleIndex == 11 || c.RoleIndex == 12)
         {
             menuitems.Append(ListContent.Repeat('\t', depth) + c.Name + "\n");
             ParseSubMenu(menuitems, c, depth + 1);
         }
     }
 }
 internal override void Update(TreeNodeData tnd, bool allowUnsafeChanges, MainForm mf)
 {
     currentAccObj = ((AccessibilityData)tnd).AccObj;
     UpdateControls();
 }