Esempio n. 1
0
        private static IList <TreeNodeData> GetWindows(WindowCache wc, MainForm mf, Process proc, ProcessThread thread, bool visibleOnly)
        {
            IList <SystemWindow> windows;

            if (thread != null)
            {
                windows = wc.WindowsByThread(thread, visibleOnly);
            }
            else if (proc != null)
            {
                windows = wc.WindowsByProcess(proc, visibleOnly);
            }
            else if (visibleOnly)
            {
                windows = wc.AllVisibleWindows;
            }
            else
            {
                windows = wc.AllWindows;
            }
            List <TreeNodeData> result = new List <TreeNodeData>();

            foreach (SystemWindow w in windows)
            {
                result.Add(new WindowData(mf, w));
            }
            return(result);
        }
Esempio n. 2
0
        internal static IList <TreeNodeData> GetThreads(WindowCache wc, MainForm mf, Process parent, bool visibleOnly)
        {
            List <TreeNodeData> result = new List <TreeNodeData>();

            if (parent == null)
            {
                foreach (Process p in Process.GetProcesses())
                {
                    foreach (ProcessThread t in p.Threads)
                    {
                        if (!visibleOnly || wc.IsThreadVisible(t))
                        {
                            result.Add(new ThreadData(mf, p, t));
                        }
                    }
                }
            }
            else
            {
                foreach (ProcessThread t in parent.Threads)
                {
                    if (!visibleOnly || wc.IsThreadVisible(t))
                    {
                        result.Add(new ThreadData(mf, parent, t));
                    }
                }
            }
            return(result);
        }
Esempio n. 3
0
 internal static bool HasAccessibilityObjectsOrBelow(WindowCache wc, MainForm mf, Process proc, ProcessThread thread, SystemWindow sw, bool visibleOnly)
 {
     if (!mf.DisplayAccObjs)
     {
         return(false);
     }
     if (sw != null)
     {
         return(true);
     }
     else
     {
         IList <SystemWindow> windows;
         if (thread != null)
         {
             windows = wc.WindowsByThread(thread, visibleOnly);
         }
         else if (proc != null)
         {
             windows = wc.WindowsByProcess(proc, visibleOnly);
         }
         else
         {
             return(true);
         }
         return(windows.Count > 0);
     }
 }
Esempio n. 4
0
 internal static bool HasThreadsOrBelow(WindowCache wc, MainForm mf, Process process, bool visibleOnly)
 {
     if (mf.DisplayThreads)
     {
         if (process == null)
         {
             return(true);                 // there must be at least the thread executing this code :)
         }
         if (visibleOnly)
         {
             foreach (ProcessThread pt in process.Threads)
             {
                 if (wc.IsThreadVisible(pt))
                 {
                     return(true);
                 }
             }
             return(false);
         }
         return(process.Threads.Count > 0);
     }
     else
     {
         return(WindowData.HasWindowsOrBelow(wc, mf, process, null, visibleOnly));
     }
 }
Esempio n. 5
0
 internal override bool HasChildren(WindowCache wc, bool visibleOnly)
 {
     if (mf.DisplayWindows == 2)
     {
         foreach (SystemWindow w in sw.AllChildWindows)
         {
             if (!visibleOnly || w.Visible)
             {
                 return(true);
             }
         }
     }
     if (mf.DisplayAccObjs)
     {
         if (sw == null)
         {
             throw new Exception();
         }
         try
         {
             SystemAccessibleObject sao = SystemAccessibleObject.FromWindow(sw, AccessibleObjectID.OBJID_WINDOW);
             if (!visibleOnly || sao.Visible)
             {
                 return(true);
             }
         }
         catch (COMException) { }
     }
     return(false);
 }
Esempio n. 6
0
 private void refreshTree(WindowCache wc)
 {
     this.Cursor  = Cursors.WaitCursor;
     tree.Visible = false;
     refreshNode(wc, tree.Nodes[0], false);
     tree.Visible = true;
     this.Cursor  = null;
 }
Esempio n. 7
0
 internal static IList <TreeNodeData> GetThreadsOrBelow(WindowCache wc, MainForm mf, Process parent, bool visibleOnly)
 {
     if (mf.DisplayThreads)
     {
         return(GetThreads(wc, mf, parent, visibleOnly));
     }
     else
     {
         return(WindowData.GetWindowsOrBelow(wc, mf, parent, null, visibleOnly));
     }
 }
Esempio n. 8
0
 public static IList <TreeNodeData> GetWindowsOrBelow(WindowCache wc, MainForm mf, Process proc, ProcessThread thread, bool visibleOnly)
 {
     if (mf.DisplayWindows > 0)
     {
         return(GetWindows(wc, mf, proc, thread, visibleOnly));
     }
     else
     {
         return(AccessibilityData.GetAccessibilityObjectsOrBelow(wc, mf, proc, thread, null, visibleOnly));
     }
 }
Esempio n. 9
0
 internal override bool HasChildren(WindowCache wc, bool visibleOnly)
 {
     if (mf.DisplayProcesses == 2)
     {
         return(ThreadData.HasThreadsOrBelow(wc, mf, process, visibleOnly) ||
                HasChildProcesses(wc, mf, visibleOnly));
     }
     else
     {
         return(ThreadData.HasThreadsOrBelow(wc, mf, process, visibleOnly));
     }
 }
Esempio n. 10
0
 internal override IList <TreeNodeData> GetChildren(WindowCache wc, bool visibleOnly)
 {
     if (mf.DisplayProcesses == 2)
     {
         List <TreeNodeData> result = new List <TreeNodeData>();
         result.AddRange(ThreadData.GetThreadsOrBelow(wc, mf, process, visibleOnly));
         result.AddRange(GetChildProcesses(wc, mf, process.Id, visibleOnly));
         return(result);
     }
     else
     {
         return(ThreadData.GetThreadsOrBelow(wc, mf, process, visibleOnly));
     }
 }
Esempio n. 11
0
        internal static IList <TreeNodeData> GetAllProcesses(WindowCache wc, MainForm mf, bool visibleOnly)
        {
            List <TreeNodeData> result = new List <TreeNodeData>();

            foreach (Process p in Process.GetProcesses())
            {
                if (!visibleOnly || wc.IsProcessVisible(p))
                {
                    result.Add(new ProcessData(mf, p));
                }
            }
            sortProcesses(result);
            return(result);
        }
Esempio n. 12
0
        private static IList <TreeNodeData> GetChildProcesses(WindowCache wc, MainForm mf, int pid, bool visibleOnly)
        {
            List <TreeNodeData> result = new List <TreeNodeData>();

            foreach (Process p in wc.ChildProcesses(pid))
            {
                if (!visibleOnly || wc.IsProcessVisible(p))
                {
                    result.Add(new ProcessData(mf, p));
                }
            }
            sortProcesses(result);
            return(result);
        }
Esempio n. 13
0
        private void refreshNode(WindowCache wc, TreeNode node, bool forceChildren)
        {
            TreeNodeData tnd = (TreeNodeData)node.Tag;

            node.ImageIndex = node.SelectedImageIndex = tnd.Icon;
            node.Text       = tnd.Name;
            if (node.Nodes.Count == 1 && node.Nodes[0].Tag is string)
            {
                return;
            }
            if (node.Nodes.Count == 0 && tnd.HasChildren(wc, visibleObjectsOnlyToolStripMenuItem.Checked) && !node.IsExpanded && !forceChildren)
            {
                node.Nodes.Add("");
                node.Nodes[0].Tag = "";
                return;
            }
            IList <TreeNodeData> children = tnd.GetChildren(wc, visibleObjectsOnlyToolStripMenuItem.Checked);

            bool[] found = new bool[children.Count];
            for (int i = 0; i < node.Nodes.Count; i++)
            {
                TreeNode     n   = node.Nodes[i];
                TreeNodeData nd  = (TreeNodeData)n.Tag;
                int          pos = children.IndexOf(nd);
                if (pos == -1)
                {
                    node.Nodes.RemoveAt(i);
                    removeFromExistingNodes(n, nd);
                    i--;
                }
                else
                {
                    found[pos] = true;
                    refreshNode(wc, n, false);
                }
            }
            for (int i = 0; i < children.Count; i++)
            {
                if (!found[i] && !existingNodes.ContainsKey(children[i]))
                {
                    TreeNode newnode = new TreeNode();
                    newnode.Tag = children[i];
                    node.Nodes.Add(newnode);
                    existingNodes.Add(children[i], newnode);
                    refreshNode(wc, newnode, false);
                }
            }
        }
Esempio n. 14
0
        internal override IList <TreeNodeData> GetChildren(WindowCache wc, bool visibleOnly)
        {
            List <TreeNodeData> result = new List <TreeNodeData>();

            foreach (SystemAccessibleObject child in accobj.Children)
            {
                if (mf.DisplayWindows != 2 || child.Window.HWnd == accobj.Window.HWnd)
                {
                    if (!visibleOnly || child.Visible)
                    {
                        result.Add(new AccessibilityData(mf, child));
                    }
                }
            }
            return(result);
        }
Esempio n. 15
0
 internal override bool HasChildren(WindowCache wc, bool visibleOnly)
 {
     if (visibleOnly)
     {
         foreach (SystemAccessibleObject child in accobj.Children)
         {
             if (child.Visible)
             {
                 return(true);
             }
         }
         return(false);
     }
     else
     {
         return(accobj.Children.Length != 0);
     }
 }
Esempio n. 16
0
 private bool HasChildProcesses(WindowCache wc, MainForm mf, bool visibleOnly)
 {
     if (visibleOnly)
     {
         foreach (Process p in wc.ChildProcesses(this.process.Id))
         {
             if (wc.IsProcessVisible(p))
             {
                 return(true);
             }
         }
         return(false);
     }
     else
     {
         return(wc.ChildProcesses(this.process.Id).Count > 0);
     }
 }
Esempio n. 17
0
 internal static bool HasWindowsOrBelow(WindowCache wc, MainForm mf, Process proc, ProcessThread thread, bool visibleOnly)
 {
     if (mf.DisplayWindows > 0)
     {
         if (proc == null)
         {
             return(true);
         }
         if (thread == null)
         {
             return(wc.WindowsByProcess(proc, visibleOnly).Count > 0);
         }
         return(wc.WindowsByThread(thread, visibleOnly).Count > 0);
     }
     else
     {
         return(AccessibilityData.HasAccessibilityObjectsOrBelow(wc, mf, proc, thread, null, visibleOnly));
     }
 }
Esempio n. 18
0
        internal override IList <TreeNodeData> GetChildren(WindowCache wc, bool visibleOnly)
        {
            List <TreeNodeData> result = new List <TreeNodeData>();

            if (mf.DisplayWindows == 2)
            {
                foreach (SystemWindow w in sw.AllChildWindows)
                {
                    if (!visibleOnly || w.Visible)
                    {
                        result.Add(new WindowData(mf, w));
                    }
                }
            }
            if (mf.DisplayAccObjs)
            {
                AccessibilityData.AddAccessibleObjects(result, mf, sw, visibleOnly);
            }
            return(result);
        }
Esempio n. 19
0
        internal override IList <TreeNodeData> GetChildren(WindowCache wc, bool visibleOnly)
        {
            IList <TreeNodeData> cc = (IList <TreeNodeData>)wc.Get(this);

            if (cc == null)
            {
                if (mf.DisplayProcesses == 1)
                {
                    cc = ProcessData.GetAllProcesses(wc, mf, visibleOnly);
                }
                else if (mf.DisplayProcesses == 2)
                {
                    cc = ProcessData.GetToplevelProcesses(wc, mf, visibleOnly);
                }
                else
                {
                    cc = ThreadData.GetThreadsOrBelow(wc, mf, null, visibleOnly);
                }
                wc.Add(this, cc);
            }
            return(cc);
        }
Esempio n. 20
0
        public static IList <TreeNodeData> GetAccessibilityObjectsOrBelow(WindowCache wc, MainForm mf, Process proc, ProcessThread thread, SystemWindow sw, bool visibleOnly)
        {
            List <TreeNodeData> result = new List <TreeNodeData>();

            if (mf.DisplayAccObjs)
            {
                if (sw != null)
                {
                    AddAccessibleObjects(result, mf, sw, visibleOnly);
                }
                else
                {
                    IList <SystemWindow> windows;
                    if (thread != null)
                    {
                        windows = wc.WindowsByThread(thread, visibleOnly);
                    }
                    else if (proc != null)
                    {
                        windows = wc.WindowsByProcess(proc, visibleOnly);
                    }
                    else if (visibleOnly)
                    {
                        windows = wc.AllVisibleWindows;
                    }
                    else
                    {
                        windows = wc.AllWindows;
                    }
                    foreach (SystemWindow w in windows)
                    {
                        AddAccessibleObjects(result, mf, w, visibleOnly);
                    }
                }
            }
            return(result);
        }
Esempio n. 21
0
 internal static IList <TreeNodeData> GetToplevelProcesses(WindowCache wc, MainForm mf, bool visibleOnly)
 {
     return(GetChildProcesses(wc, mf, 0, visibleOnly));
 }
Esempio n. 22
0
 internal override IList <TreeNodeData> GetChildren(WindowCache wc, bool visibleOnly)
 {
     return(WindowData.GetWindowsOrBelow(wc, mf, process, thread, visibleOnly));
 }
Esempio n. 23
0
 private TreeNode findNode(WindowCache wc, SelectableTreeNodeData wd)
 {
     if (wd is WindowData)
     {
         if (wc.AddUnlisted(((WindowData)wd).Window))
         {
             MessageBox.Show("This Window is not included in EnumWindows");
         }
     }
     if (!existingNodes.ContainsKey(wd))
     {
         IList <TreeNodeData> parents = wd.PossibleParents;
         TreeNode             curr    = tree.Nodes[0];
         foreach (TreeNodeData p in parents)
         {
             if (existingNodes.ContainsKey(p))
             {
                 curr = existingNodes[p];
                 break;
             }
         }
         while (!curr.Tag.Equals(wd))
         {
             if (curr.Nodes.Count == 1 && curr.Nodes[0].Tag is string)
             {
                 curr.Nodes.Clear();
                 refreshNode(wc, curr, true);
             }
             bool found = false;
             foreach (TreeNodeData parent in parents)
             {
                 foreach (TreeNode n in curr.Nodes)
                 {
                     if (n.Tag.Equals(parent))
                     {
                         curr  = n;
                         found = true;
                         break;
                     }
                 }
                 if (found)
                 {
                     break;
                 }
             }
             if (!found)
             {
                 refreshNode(wc, curr, true);
                 foreach (TreeNodeData parent in parents)
                 {
                     foreach (TreeNode n in curr.Nodes)
                     {
                         if (n.Tag.Equals(parent))
                         {
                             curr  = n;
                             found = true;
                             break;
                         }
                     }
                     if (found)
                     {
                         break;
                     }
                 }
             }
             if (!found)
             {
                 MessageBox.Show("Could not find window below " + curr.Text);
                 return(null);
             }
         }
         if (existingNodes[wd] != curr)
         {
             throw new Exception();
         }
     }
     return(existingNodes[wd]);
 }
Esempio n. 24
0
 internal abstract bool HasChildren(WindowCache wc, bool visibleOnly);
Esempio n. 25
0
 internal override bool HasChildren(WindowCache wc, bool visibleOnly)
 {
     return(GetChildren(wc, visibleOnly).Count > 0);
 }
Esempio n. 26
0
 internal abstract IList <TreeNodeData> GetChildren(WindowCache wc, bool visibleOnly);
Esempio n. 27
0
 internal override bool HasChildren(WindowCache wc, bool visibleOnly)
 {
     return(WindowData.HasWindowsOrBelow(wc, mf, process, thread, visibleOnly));
 }