Exemplo n.º 1
0
        protected override WindowContent ParseContent(SystemWindow sw)
        {
            SystemAccessibleObject sao = SystemAccessibleObject.FromWindow(sw, AccessibleObjectID.OBJID_CLIENT);

            if (sao.RoleIndex == 35)
            {
                List <string> treeNodes = new List <string>();
                int           selected  = -1;
                foreach (SystemAccessibleObject n in sao.Children)
                {
                    if (n.RoleIndex == 36)
                    {
                        if ((n.State & 0x2) != 0)
                        {
                            selected = treeNodes.Count;
                        }
                        treeNodes.Add(ListContent.Repeat('\t', int.Parse(n.Value)) + n.Name);
                    }
                }
                if (treeNodes.Count > 0)
                {
                    return(new ListContent("TreeView", selected, null, treeNodes.ToArray()));
                }
            }
            return(new ListContent("EmptyTreeView", -1, null, new string[0]));
        }
Exemplo n.º 2
0
 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);
         }
     }
 }
        private void ParseClientAreaElement(StringBuilder sb, SystemAccessibleObject sao, int depth)
        {
            sb.Append("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
            sb.Append(ListContent.Repeat('*', depth)).Append(' ').Append(sao).Append('\n');
            try {
                sb.Append("D: ").Append(sao.Description).Append('\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);
                }
            }
        }
Exemplo n.º 4
0
 private void ParseClientAreaElement(StringBuilder stringBuilder, SystemAccessibleObject systemAccessibleObject, int depth)
 {
     stringBuilder.Append("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
     stringBuilder.Append(ListContent.Repeat('*', depth) + " " + systemAccessibleObject + "\n");
     try
     {
         stringBuilder.Append("D: " + systemAccessibleObject.Description + "\n");
     }
     catch (COMException) { }
     try
     {
         stringBuilder.Append("V: " + systemAccessibleObject.Value + "\n");
     }
     catch (COMException) { }
     foreach (SystemAccessibleObject c in systemAccessibleObject.Children)
     {
         if (c.Window == systemAccessibleObject.Window)
         {
             ParseClientAreaElement(stringBuilder, c, depth + 1);
         }
     }
 }
Exemplo n.º 5
0
        protected override WindowContent ParseContent(SystemWindow sw)
        {
            uint LVM_GETITEMCOUNT = (0x1000 + 4);
            int  cnt = sw.SendGetMessage(LVM_GETITEMCOUNT);

            if (cnt == 0)
            {
                throw new Exception();
            }
            SystemAccessibleObject o = SystemAccessibleObject.FromWindow(sw, AccessibleObjectID.OBJID_CLIENT);

            if (o.RoleIndex == 33)
            {
                // are there column headers?
                int      cs  = o.Children.Length;
                string[] hdr = null;
                if (cs > 0)
                {
                    SystemAccessibleObject headers = o.Children[cs - 1];
                    if (headers.RoleIndex == 9 && headers.Window != sw)
                    {
                        SystemAccessibleObject hdrL = SystemAccessibleObject.FromWindow(headers.Window, AccessibleObjectID.OBJID_CLIENT);
                        hdr = new string[hdrL.Children.Length];
                        for (int i = 0; i < hdr.Length; i++)
                        {
                            if (hdrL.Children[i].RoleIndex != 25)
                            {
                                hdr = null;
                                break;
                            }
                            hdr[i] = hdrL.Children[i].Name;
                        }
                        if (hdr != null)
                        {
                            cs--;
                        }
                    }
                }
                List <string> values = new List <string>();
                for (int i = 0; i < cs; i++)
                {
                    if (o.Children[i].RoleIndex == 34)
                    {
                        string name = o.Children[i].Name;
                        if (hdr != null)
                        {
                            try
                            {
                                string cols = o.Children[i].Description;
                                if (cols == null && values.Count == 0)
                                {
                                    hdr = null;
                                }
                                else
                                {
                                    string        tmpCols = "; " + cols;
                                    List <string> usedHdr = new List <string>();
                                    foreach (string header in hdr)
                                    {
                                        string h = "; " + header + ": ";
                                        if (tmpCols.Contains(h))
                                        {
                                            usedHdr.Add(header);
                                            tmpCols = tmpCols.Substring(tmpCols.IndexOf(h) + h.Length);
                                        }
                                    }
                                    foreach (string header in hdr)
                                    {
                                        name += "\t";
                                        if (usedHdr.Count > 0 && usedHdr[0] == header)
                                        {
                                            if (!cols.StartsWith(header + ": "))
                                            {
                                                throw new Exception();
                                            }
                                            cols = cols.Substring(header.Length + 1);
                                            string elem;
                                            if (usedHdr.Count > 1)
                                            {
                                                int pos = cols.IndexOf("; " + usedHdr[1] + ": ");
                                                elem = cols.Substring(0, pos);
                                                cols = cols.Substring(pos + 2);
                                            }
                                            else
                                            {
                                                elem = cols;
                                                cols = "";
                                            }
                                            name += elem;
                                            usedHdr.RemoveAt(0);
                                        }
                                    }
                                }
                            }
                            catch (COMException ex)
                            {
                                if (ex.ErrorCode == -2147352573 && values.Count == 0)
                                {
                                    hdr = null;
                                }
                                else
                                {
                                    throw ex;
                                }
                            }
                        }
                        values.Add(name);
                    }
                }
                if (hdr != null)
                {
                    string lines = "", headers = "";
                    foreach (string h in hdr)
                    {
                        if (lines.Length > 0)
                        {
                            lines += "\t";
                        }
                        if (headers.Length > 0)
                        {
                            headers += "\t";
                        }
                        headers += h;
                        lines   += ListContent.Repeat('~', h.Length);
                    }
                    values.Insert(0, lines);
                    values.Insert(0, headers);
                    return(new ListContent("DetailsListView", -1, null, values.ToArray()));
                }
                else
                {
                    return(new ListContent("ListView", -1, null, values.ToArray()));
                }
            }
            else
            {
                return(new ListContent("EmptyListView", -1, null, new string[0]));
            }
        }