//验证 第三种:需要回答验证问题的 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); }
public static void add(String _info, String _desc, int _state) { if (dics.ContainsKey(_info)) { return; } AddFriInfo afi = new AddFriInfo(); afi.state = _state; afi.desc = _desc; afi.info = _info; dics.Add(_info, afi); String pathName = "addfriinfo.txt"; FileStream aFile = new FileStream(pathName, FileMode.Create); StreamWriter sw = new StreamWriter(aFile); foreach (AddFriInfo _d in dics.Values) { String _l = String.Format("{0}\t{1}\t{2}\n", _d.info, _d.desc, _d.state); sw.Write(_l); } sw.Close(); }
//身份验证窗口 //验证 第一种:需要输入正确答案的(放弃吧) 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); }
public static void read() { String pathName = "addfriinfo.txt"; if (File.Exists(pathName)) { FileStream aFile = new FileStream(pathName, FileMode.Open); StreamReader sr = new StreamReader(aFile); String strLine = sr.ReadLine(); //Read data in line by line 这个兄台看的懂吧~一行一行的读取 while (strLine != null) { String[] ps = strLine.Split('\t'); AddFriInfo afi = new AddFriInfo(); afi.state = Convert.ToInt32(ps[2]); afi.desc = ps[1]; afi.info = ps[0]; dics.Add(afi.info, afi); strLine = sr.ReadLine(); } sr.Close(); } }