private void Form2_Load(object sender, EventArgs e) { _currentDevice = this.Name as string; //初始化分辨率 wmPointModel = baseAction.GetWMSize(_currentDevice); this.pictureBoxSame.Name = string.Format(string.Format("Big_{0}", partialControlName), _currentDevice); this.pictureBoxSame.Tag = string.Format(partialControlName, _currentDevice); this.pictureBoxSame.BackColor = Color.Black; this.pictureBoxSame.Image = this.Tag as Image; baseAction.CurrentSameScreenControl = this.pictureBoxSame; var allCheckBox = new CheckBox() { Text = "全选", Name = "allCheck", ForeColor = Color.DarkTurquoise, TextAlign = ContentAlignment.MiddleLeft }; allCheckBox.CheckedChanged += (er, obj) => { var checkBox = er as CheckBox; CheckAllAndUpdateUI(this.flowLayoutPanelWithEquipment, checkBox); }; this.flowLayoutPanelWithEquipment.Controls.Add(allCheckBox); CheckSomeEquipmentToDO(this.flowLayoutPanelWithEquipment, new DeviceToNickNameViewModel() { Device = _currentDevice }); InitGroup(this.panelWithSameScreenGroup); }
/// <summary> /// 发布宝贝页面 /// </summary> public void PublishPage(IdleFishActionViewModel idleFishViewModel, WMPoint wmPoint) { var currentViewModel = idleFishViewModel; currentViewModel.XMLName = "publishactivity"; ///分析布局 Action <IdleFishActionViewModel, string, XmlDocument, Action <IdleFishActionViewModel, WMPoint> > func = (model, xmlSelectStr, doc, action) => { ///标题 XmlNode node = doc.SelectSingleNode(xmlSelectStr); var strValue = node.Attributes["bounds"].Value; var returnData = baseAction.GetStartBoundsWithEndBounds <IdleFishActionViewModel>(model, strValue); returnData.CurrentContent = returnData.Title; if (xmlSelectStr.Contains("content")) { returnData.CurrentContent = returnData.Description; } action(returnData, wmPoint); }; baseAction.CreatUIXML <IdleFishActionViewModel>(currentViewModel, (o, doc) => { ///标题 func(o, "//node[@resource-id='com.taobao.idlefish:id/title']", doc, TxtAction); ///描述 func(o, "//node[@resource-id='com.taobao.idlefish:id/content']", doc, TxtAction); ///价格 func(o, "//node[@resource-id='com.taobao.idlefish:id/price']", doc, PriceAction); //分类 func(o, "//node[@resource-id='com.taobao.idlefish:id/cate_name']", doc, CategoryAction); //确认发布按钮 func(o, "//node[@resource-id='com.taobao.idlefish:id/publish_button']", doc, ClickAction); return(o); }); }
//进入新朋友页面 public void EnterNewFriendPageAction(WXActionViewModel viewModel, WMPoint wmPoint = null) { _baseAction.UnlockSingleScreen(viewModel.Device); OpenWX(viewModel.Device, wmPoint); //viewModel.PullNativePath = string.Format(@"{0}\{1}", SingleHepler<ConfigInfo>.Instance.CutImageFileUrl, viewModel.Device); ////通讯录 _baseAction.actionDirectStr(viewModel.Device, 300, 1180, wmPoint); Thread.Sleep(2000); ////新朋友 _baseAction.actionDirectStr(viewModel.Device, 100, 230, wmPoint); //检测是否进入新的朋友界面 var isSuccess = _baseAction.CircleDetection("FMessageConversationUI", viewModel.Device); if (!isSuccess) { return; } }
private void OpenWX(string device, WMPoint wmPointModel = null) { _baseAction.OpenApp(device, "com.tencent.mm", "com.tencent.mm/com.tencent.mm.ui.LauncherUI", (action) => { var stateStr = string.Empty; if (wmPointModel == null) { wmPointModel = _baseAction.GetWMSize(device); } while (!stateStr.Contains("PopupWindow")) { ///向上滑动 防止出现通知 _baseAction.InitProcessWithTaskState(device, " shell input swipe 100 100 600 100"); _baseAction.actionDirectStr(device, 700, 100, wmPointModel); stateStr = action(stateStr); } _baseAction.actionDirectStr(device, 700, 100, wmPointModel); }); }
/// <summary> /// 统计粉丝数 /// </summary> /// <param name="viewModel"></param> public void StatisticsFriendCount(WXActionViewModel viewModel, WMPoint wmPoint) { _baseAction.UnlockSingleScreen(viewModel.Device); OpenWX(viewModel.Device); ////通讯录 _baseAction.actionDirectStr(viewModel.Device, 300, 1180, wmPoint); ///点击 # var y = 1060; if (!string.IsNullOrEmpty(viewModel.Device) && viewModel.Device.Length <= 8) { y += _baseAction.DValue; } _baseAction.actionDirectStr(viewModel.Device, 700, y, wmPoint); //viewModel.PullNativePath = string.Format(@"{0}\{1}", SingleHepler<ConfigInfo>.Instance.CutImageFileUrl, viewModel.Device); viewModel.XMLName = "recordUI"; while (string.IsNullOrEmpty(viewModel.FriendCountStr)) { ///滑动进入到页面最低端 _baseAction.InitProcessWithTaskState(viewModel.Device, "shell input swipe 100 1000 100 -10000"); ///获取通讯录页面的XML文档 viewModel = _baseAction.CreatUIXML(viewModel, (o, doc) => { XmlNode callOnNode1 = doc.SelectSingleNode("//node[contains(@bounds,'[0,1060]')]"); XmlNode callOnNode2 = doc.SelectSingleNode("//node[contains(@text,'位联系人')]"); if (callOnNode1 != null) { callOnNode1 = callOnNode1.LastChild; o.FriendCountStr = GetFansCountByStr(callOnNode1.InnerXml); } else if (null != callOnNode2) { var value = callOnNode2.Attributes["text"].Value; if (!string.IsNullOrEmpty(value)) { o.FriendCountStr = Regex.Match(value, @"(\d+)").Value; } } return(o); }); Thread.Sleep(500); } Task.Factory.StartNew(() => { SingleHepler <DeviceToNickNameBLL> .Instance.UpDateFriendCount(new DeviceToNickNameViewModel() { Device = viewModel.Device, FriendCount = int.Parse(viewModel.FriendCountStr) }); }); }
public void FromDetailPageToValidatePage(WXActionViewModel viewModel, Action <bool> currentAction = null, WMPoint wmPoint = null) { var isSuccess = true; ///可以执行下去 if (!viewModel.IsGoOn) { return; } ///点击添加到通讯录按钮 或者 验证通过按钮 _baseAction.InitProcessWithTaskState(viewModel.Device, string.Format("shell input tap {0} {1}", (viewModel.LeftWidth + viewModel.RightWidth) / 2, (viewModel.TopHeight + viewModel.BottomHeight) / 2)); ///检测是直接变成好友 还是进入验证页面 var isContinueing = true; while (isContinueing) { var list = _baseAction.InitProcessWithTaskState(viewModel.Device, " shell dumpsys window | grep mCurrentFocus", true); if (null == list || list.Count == 0) { isSuccess = false; isContinueing = false; } ///检测是否进入验证页面 if (string.Join("|", list).Contains("SayHiWithSnsPermissionUI")) { isSuccess = true; isContinueing = false; } ///检测是否直接变成 发送消息 else { var returnData = _baseAction.CreatUIXML(viewModel, (o, doc) => { return(CheckIsTurnDirectlyNewFriend(doc)); }); ///表示 就是直接变成发消息 不用验证 if (returnData.IsValidatedState) { isSuccess = false; isContinueing = false; } } } if (isSuccess) { ///进入的是打招呼界面 isSuccess = EnterSayHelloActivity(viewModel, wmPoint); if (null != currentAction) { currentAction.Invoke(isSuccess); } } }
/// <summary> /// 通过联系人加好友 /// </summary> /// <param name="viewModel"></param> public void AddFriendWithContracts(WXActionViewModel viewModel, WMPoint wmPoint) { var y = 443; var i = 1; var isValidate = false; var stateStr = string.Empty; var isSuccess = false; viewModel.XMLName = "deleteAddedFriend"; while (i <= viewModel.AddCount) { ///检测设备是否处于连接状态 if (_baseAction.CheckEquipmentIsConnecting(viewModel.Device)) { return; } stateStr = string.Empty; isSuccess = false; var returnModel = IsHaveNewFriend(viewModel); if (!returnModel.IsValidatedState) { return; } returnModel = DeleteFriend(viewModel); if (!returnModel.IsValidatedState) { ///长按当前新朋友 _baseAction.actionDirectSwipStr(viewModel.Device, 100, y, 100, y, wmPoint); ///删除当前新朋友 _baseAction.actionDirectStr(viewModel.Device, 360, 640, wmPoint); } else { #region 加好友 _baseAction.actionDirectStr(viewModel.Device, 100, y, wmPoint); //检测是否进入详细资料 isSuccess = _baseAction.CircleDetection("ContactInfoUI", viewModel.Device); if (!isSuccess) { return; } viewModel.IsGoOn = true; viewModel.XMLName = "DetailUI"; viewModel = _baseAction.CreatUIXML(viewModel, (o, doc) => { return(BeforeAddFriendWithValidate(doc, o)); }); ///页面过渡的时候检测 FromDetailPageToValidatePage(viewModel, (o) => { if (o) { i++; } }, wmPoint); //点击去除不必要的弹框 // _baseAction.InitProcessWithTaskState(viewModel.Device, "shell input tap 360 100"); //返回到新朋友 _baseAction.actionDirectStr(viewModel.Device, 50, 100, wmPoint); //检测是否进入新朋友界面 isSuccess = _baseAction.CircleDetection("FMessageConversationUI", viewModel.Device); if (isSuccess) { ///长按当前新朋友 _baseAction.actionDirectSwipStr(viewModel.Device, 100, y, 100, y, wmPoint); ///删除当前新朋友 _baseAction.actionDirectStr(viewModel.Device, 360, 640, wmPoint); } #endregion } } }
/// <summary> /// 通过搜索加好友 /// </summary> /// <param name="viewModel"></param> public void AddFriendWithSearch(WXActionViewModel viewModel, WMPoint wmPoint) { var searchContentList = viewModel.SearchContents; if (null == searchContentList || searchContentList.Count == 0) { return; } ///点击添加朋友 _baseAction.actionDirectStr(viewModel.Device, 700, 100, wmPoint); ///是否进入添加朋友界面 var isSuccess = _baseAction.CircleDetection("AddMoreFriendsUI", viewModel.Device); if (!isSuccess) { return; } //点击搜索框 _baseAction.actionDirectStr(viewModel.Device, 360, 250, wmPoint); ///是否进入搜索界面 isSuccess = _baseAction.CircleDetection("FTSAddFriendUI", viewModel.Device); if (!isSuccess) { return; } foreach (var searchContent in searchContentList) { viewModel.IsGoOn = true; viewModel.XMLName = "DetailUI"; ///检测设备是否处于连接状态 if (_baseAction.CheckEquipmentIsConnecting(viewModel.Device)) { break; } ///清空输入框 _baseAction.actionDirectStr(viewModel.Device, 700, 100, wmPoint); ///输入搜索内容 _baseAction.InitProcessWithTaskState(viewModel.Device, "shell am broadcast -a ADB_INPUT_TEXT --es msg '" + searchContent + "'"); ///点击搜索按钮 _baseAction.actionDirectStr(viewModel.Device, 360, 200, wmPoint); //检测是否进入详细资料 isSuccess = _baseAction.CircleDetection("ContactInfoUI", viewModel.Device); if (!isSuccess) { continue; } viewModel = _baseAction.CreatUIXML(viewModel, (o, doc) => { return(BeforeAddFriendWithValidate(doc, o)); }); FromDetailPageToValidatePage(viewModel, wmPoint: wmPoint); //返回 _baseAction.actionDirectStr(viewModel.Device, 50, 100, wmPoint); } }
/// <summary> /// 单个发送朋友圈 /// </summary> /// <param name="device"></param>- public void SendFriendCircle(UploadFilesToPhoneViewModel viewModel) { ///检测设备是否处于连接状态 if (_baseAction.CheckEquipmentIsConnecting(viewModel.Device)) { return; } var isSuccess = false; _baseAction.UnlockSingleScreen(viewModel.Device); OpenWX(viewModel.Device); ///获取屏幕分辨率 WMPoint wmPoint = _baseAction.GetWMSize(viewModel.Device); ////我 _baseAction.actionDirectStr(viewModel.Device, 700, 1180, wmPoint); //////相册 _baseAction.actionDirectStr(viewModel.Device, 450, 650, wmPoint); //检测是否进入我的相册 isSuccess = _baseAction.CircleDetection("SnsUserUI", viewModel.Device); if (!isSuccess) { return; } /////今天 _baseAction.actionDirectStr(viewModel.Device, 200, 910, wmPoint); /////从相册中选择 _baseAction.actionDirectStr(viewModel.Device, 360, 700, wmPoint); ///是否进入相册列表 isSuccess = _baseAction.CircleDetection("AlbumPreviewUI", viewModel.Device); if (!isSuccess) { //滑动一下 去除通知 _baseAction.InitProcessWithTaskState(viewModel.Device, " shell input swipe 100 100 600 100"); ///去除意外弹框 _baseAction.actionDirectStr(viewModel.Device, 200, 100, wmPoint); /////今天 _baseAction.actionDirectStr(viewModel.Device, 200, 900, wmPoint); /////从相册中选择 _baseAction.actionDirectStr(viewModel.Device, 360, 700, wmPoint); isSuccess = _baseAction.CircleDetection("AlbumPreviewUI", viewModel.Device); if (!isSuccess) { return; } } ///选择照片 _baseAction.SelectImage(viewModel.Files, wmPoint, viewModel.Device, 120, 200, 120, 180); ///发送的是视频 if (viewModel.PublishContentType == EnumPublishContentType.VedioAndWord) { //检测是否进入视频预览界面 isSuccess = _baseAction.CircleDetection("ImagePreviewUI", viewModel.Device); if (!isSuccess) { return; } } ///向上滑动 防止出现通知 _baseAction.InitProcessWithTaskState(viewModel.Device, " shell input swipe 100 100 600 100"); ////完成 _baseAction.actionDirectStr(viewModel.Device, 700, 100, wmPoint); Thread.Sleep(1000); var list = _baseAction.InitProcessWithTaskState(viewModel.Device, " shell dumpsys window | grep mCurrentFocus", true); var stateStr = list.FirstOrDefault(); //检测是否进入确定发送朋友圈页面 while (stateStr.Contains("AlbumPreviewUI") || stateStr.Contains("ImagePreviewUI") || stateStr.Contains("VideoCompressUI")) { list = _baseAction.InitProcessWithTaskState(viewModel.Device, " shell dumpsys window | grep mCurrentFocus", true); stateStr = list.FirstOrDefault(); } ///点击text 获取焦点 _baseAction.actionDirectStr(viewModel.Device, 100, 200, wmPoint); ///输入文字 _baseAction.InitProcessWithTaskState(viewModel.Device, "shell am broadcast -a ADB_INPUT_TEXT --es msg '" + viewModel.Content + "'"); ///向上滑动 防止出现通知 _baseAction.InitProcessWithTaskState(viewModel.Device, " shell input swipe 100 100 600 100"); // 点击确定发送朋友圈按钮 _baseAction.actionDirectStr(viewModel.Device, 700, 100, wmPoint); //Thread.Sleep(1000); //list = _baseAction.InitProcessWithTaskState(viewModel.Device, " shell dumpsys window | grep mCurrentFocus", true); //stateStr = list.FirstOrDefault(); /////是否进入朋友圈界面 //while (stateStr.Contains("SnsUploadUI")) //{ // ///向上滑动 防止出现通知 // _baseAction.InitProcessWithTaskState(viewModel.Device, " shell input swipe 100 100 600 100"); // ///点击确定发送朋友圈按钮 // _baseAction.InitProcessWithTaskState(viewModel.Device, "shell input tap 700 100"); // list = _baseAction.InitProcessWithTaskState(viewModel.Device, " shell dumpsys window | grep mCurrentFocus", true); // stateStr = list.FirstOrDefault(); // Thread.Sleep(500); //} }
/// <summary> /// 进入打招呼页面 /// </summary> public bool EnterSayHelloActivity(WXActionViewModel viewModel, WMPoint wmPoint = null) { #region 分析 打招呼页面 XML文档 viewModel.XMLName = "SayHelloPage"; Action <int, int> _currentAction = (x, y) => { _baseAction.actionDirectStr(viewModel.Device, x, y, wmPoint); }; Action <string> _currentInputContentAction = (content) => { _baseAction.InitProcessWithTaskState(viewModel.Device, "shell am broadcast -a ADB_INPUT_TEXT --es msg '" + content + "'"); }; //_currentAction.Invoke(650, 240); _currentAction.Invoke(650, 240); var currentViewModel = _baseAction.CreatUIXML(viewModel, (o, doc) => { return(ValiDateSayHelloPage(doc, o)); }); ///表示是要发送验证申请的 if (currentViewModel.IsValidatedState) { _currentInputContentAction(viewModel.SayHiContent); ///设置备注文本框获取焦点 _currentAction.Invoke(650, 465); //删除默认备注 _currentAction.Invoke(650, 465); } if (!string.IsNullOrEmpty(viewModel.RemarkContent)) { ///输入备注 _currentInputContentAction(viewModel.RemarkContent); } else { ///点击 填入 按钮 输入备注 _currentAction.Invoke(viewModel.RightWidth - 30, viewModel.BottomHeight - 15); } #endregion ///向上滑动 防止出现通知 _baseAction.InitProcessWithTaskState(viewModel.Device, " shell input swipe 100 100 600 100"); //发送 _baseAction.actionDirectStr(viewModel.Device, 700, 100, wmPoint); //检测是否进入详细资料 有可能对方删除或者拉黑了我 会出现验证失败 不会自动返回详细资料页面 var isSuccess = _baseAction.CircleDetection("ContactInfoUI", viewModel.Device, false); if (!isSuccess) { //返回 _baseAction.actionDirectStr(viewModel.Device, 50, 100, wmPoint); } return(isSuccess); }
private void Form2_Load(object sender, EventArgs e) { _currentDevice = this.Name as string; CustomControl.RoundPanel _panel = new CustomControl.RoundPanel(); _panel.Height = this.splitContainer1.Panel1.Height - 20; _panel.Width = this.splitContainer1.Panel1.Width - 10; _panel.Location = new Point(10, 10); _panel.RoundeStyle = RoundStyle.All; _panel.Radius = 30; _panel.BorderColor = Color.Black; pictureBoxSame = new PictureBox(); pictureBoxSame.BackgroundImageLayout = ImageLayout.Stretch; pictureBoxSame.SizeMode = PictureBoxSizeMode.StretchImage; pictureBoxSame.MouseDown += PictureBox1_MouseDown; pictureBoxSame.MouseMove += PictureBox1_MouseMove; pictureBoxSame.MouseUp += PictureBox1_MouseUp; pictureBoxSame.Height = _panel.Height - 70; pictureBoxSame.Width = _panel.Width - 20; pictureBoxSame.Location = new Point(10, 30); FlowLayoutPanel fp = new FlowLayoutPanel(); fp.Height = 30; fp.Width = pictureBoxSame.Width; fp.Location = new Point(10, pictureBoxSame.Height + pictureBoxSame.Location.Y + 5); fp.Parent = _panel; var currentWidth = (fp.Width - 20) * 13 / 84; SetBottomBtn(fp, currentWidth, returnBottomBtnEvent()); this.splitContainer1.Panel1.Controls.Add(_panel); _panel.Controls.Add(pictureBoxSame); _panel.Controls.Add(fp); this.ActiveControl = pictureBoxSame; this.StartPosition = FormStartPosition.CenterParent; //初始化分辨率 wmPointModel = baseAction.GetWMSize(_currentDevice); this.pictureBoxSame.Name = string.Format(string.Format("Big_{0}", partialControlName), _currentDevice); this.pictureBoxSame.Tag = string.Format(partialControlName, _currentDevice); this.pictureBoxSame.BackColor = Color.Black; this.pictureBoxSame.Image = this.Tag as Image; baseAction.CurrentSameScreenControl = this.pictureBoxSame; var allCheckBox = new CheckBox() { Text = "全选", Name = "allCheck", ForeColor = Color.DarkTurquoise, TextAlign = ContentAlignment.MiddleLeft }; allCheckBox.CheckedChanged += (er, obj) => { var checkBox = er as CheckBox; CheckAllAndUpdateUI(this.flowLayoutPanelWithEquipment, checkBox); }; this.flowLayoutPanelWithEquipment.Controls.Add(allCheckBox); CheckSomeEquipmentToDO(this.flowLayoutPanelWithEquipment, new DeviceToNickNameViewModel() { Device = _currentDevice }); InitGroup(this.panelWithSameScreenGroup); }