/// <summary> /// 传到指定模拟器编号启动登录 /// </summary> private void AutomaticLogin(object login) { LoginInfo li = (LoginInfo)login; Task.Run(() => { //获取所有设备连接信息 List <string> devicesList = ProcessUtils.AdbDevices(); gridLListSimulators.Clear(); string txt = ""; if (this.dgAccountManagement.Items[li.index] != null) { if (((Xzy.EmbeddedApp.Model.admins) this.dgAccountManagement.Items[li.index]).login_pwd != null && ((Xzy.EmbeddedApp.Model.admins) this.dgAccountManagement.Items[li.index]).login_user != null) { if (((Xzy.EmbeddedApp.Model.admins) this.dgAccountManagement.Items[li.index]).login_pwd.Trim() != "" && ((Xzy.EmbeddedApp.Model.admins) this.dgAccountManagement.Items[li.index]).login_user.Trim() != "") { gridLListSimulators.Add(this.dgAccountManagement.Items[li.index] as Xzy.EmbeddedApp.Model.admins); } txt += ((Xzy.EmbeddedApp.Model.admins) this.dgAccountManagement.Items[li.index]).login_user.Trim() + "\r\n" + ((Xzy.EmbeddedApp.Model.admins) this.dgAccountManagement.Items[li.index]).login_pwd + "\r\n"; } } if (((Xzy.EmbeddedApp.Model.admins) this.dgAccountManagement.Items[0]).login_user != null) { string connectDeviceCmd = string.Format("{0}/adb -s {1} shell", ProcessUtils.LDPath, devicesList[li.index].ToString()); if (devicesList[li.index].IndexOf(li.port) > 0) { string cmdInputText = string.Format("input text {0}", gridLListSimulators[0].login_user); string cmdInputTap = string.Format("input tap {0} {1}", 100, 200); string cmdTab = "input keyevent 61"; string cmdPwd = string.Format("input text {0}", gridLListSimulators[0].login_pwd); string cmdLogin = string.Format("input tap {0} {1}", 100, 300); string cmdConfirm = string.Format("input tap {0} {1}", 245, 465); StreamWriter sw = new StreamWriter(@"D:\" + li.index.ToString() + ".txt"); sw.WriteLine(cmdInputTap); sw.WriteLine(cmdInputText); sw.WriteLine(cmdInputTap); sw.WriteLine(cmdTab); sw.WriteLine(cmdPwd); sw.WriteLine(cmdLogin); sw.WriteLine(cmdConfirm); sw.Close(); DeviceOperation deviceOperation = new DeviceOperation(); deviceOperation.RunText(connectDeviceCmd, @"D:\" + li.index.ToString() + ".txt"); } } }); }