예제 #1
0
        //验证 第三种:需要回答验证问题的
        static bool FriendTest3(AutomationElement appElement, bool next)
        {
            AutomationElement           element = null;
            AutomationElementCollection item    = appElement.FindAll(TreeScope.Descendants,
                                                                     new PropertyCondition(AutomationElement.ControlTypeProperty, 0xC371));

            for (int i = 0; i < item.Count; ++i)
            {
                AutomationElement tmp = item[i].FindFirst(TreeScope.Children,
                                                          new PropertyCondition(AutomationElement.ControlTypeProperty, 0xC364));
                if (tmp != null)
                {
                    string name = tmp.Current.Name;
                    if (name.Contains("对方需要你回答") && name.Contains("个验证问题"))
                    {
                        AutomationElementCollection item2 = item[i].FindAll(TreeScope.Descendants,
                                                                            new PropertyCondition(AutomationElement.ControlTypeProperty, 0xC364));
                        for (int j = 0; j < item2.Count; ++j)
                        {
                            LegacyIAccessiblePattern pattern =
                                (LegacyIAccessiblePattern)item2[j].GetCurrentPattern(LegacyIAccessiblePattern.Pattern);
                            if (pattern != null && pattern.Current.Name.Contains("问题") && !pattern.Current.Name.Contains("对方需要你回答"))
                            {
                                AddFriInfo.add(pattern.Current.Name, name, 1);
                            }
                        }

                        element = item[i];
                        break;
                    }
                }
            }

            return(element != null);
        }
예제 #2
0
        //身份验证窗口
        //验证 第一种:需要输入正确答案的(放弃吧)
        static bool FriendTest1(AutomationElement appElement)
        {
            AutomationElementCollection item = appElement.FindAll(TreeScope.Descendants,
                                                                  new PropertyCondition(AutomationElement.ControlTypeProperty, 0xC371));

            for (int i = 0; i < item.Count; ++i)
            {
                Condition[] condition = new Condition[2];
                condition[0] = new PropertyCondition(AutomationElement.ControlTypeProperty, 0xC364);
                condition[1] = new PropertyCondition(AutomationElement.ControlTypeProperty, 0xC355);
                AutomationElement element = item[i].FindFirst(TreeScope.Children, new OrCondition(condition));
                if (element != null)
                {
                    string key = element.Current.Name;
                    if (key == "对方需要你回答一下验证问题:" ||
                        key == "对方拒绝被添加" ||
                        key.Contains("已经是你的好友,不能重复添加"))
                    {
                        AutomationElementCollection item2 = item[i].FindAll(TreeScope.Descendants,
                                                                            new PropertyCondition(AutomationElement.ControlTypeProperty, 0xC364));
                        for (int j = 0; j < item2.Count; ++j)
                        {
                            LegacyIAccessiblePattern pattern =
                                (LegacyIAccessiblePattern)item2[j].GetCurrentPattern(LegacyIAccessiblePattern.Pattern);
                            if (pattern != null && pattern.Current.ChildId == 2)
                            {
                                AddFriInfo.add(pattern.Current.Name, key, 2);
                                break;
                            }
                        }
                        return(true);
                    }
                }
            }

            return(false);
        }