public void SpecialTask() { try { WlyUtilityBiz.Login(this); BindGameWnd(); var dmGuid = DMGuid; WlyViewMgr.GoTo(dmGuid, WlyViewType.功能_红包); // 点击红包 DMService.Instance.LeftClick(dmGuid, new WxPoint(498, 452), TimeSpan.FromSeconds(2)); FlowLogicHelper.RepeatRun(() => DMService.Instance.LeftClick(dmGuid, new WxPoint(434, 203)), 6); FlowLogicHelper.RepeatRun(() => DMService.Instance.LeftClick(dmGuid, new WxPoint(525, 280)), 6); FlowLogicHelper.RepeatRun(() => DMService.Instance.LeftClick(dmGuid, new WxPoint(485, 349)), 6); } catch { } finally { CloseProcess(); } }
private void HandleErrorCmdExecute(object obj) { if (m_errorAccounts == null) { var file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "error", "errorAccount.data"); m_errorAccounts = File.ReadAllLines(file).ToList(); } var uid = m_errorAccounts.FirstOrDefault(); if (uid != null) { var entity = m_subList.FirstOrDefault(o => o.AccountInfo.UID == uid); if (entity == null) { MessageBox.Show(Application.Current.MainWindow, $"未找到角色 海潮{m_startIndex:D4}"); return; } WlyUtilityBiz.Login(entity); m_errorAccounts.Remove(uid); } else { MessageBox.Show(Application.Current.MainWindow, $"错误处理完毕"); } }
private void StartIndexCmdExecute(object obj) { var entity = m_subList.FirstOrDefault(o => (o.Index.ToString() == m_startIndex) || (o.AccountInfo.UID == m_startIndex)); if (entity == null) { MessageBox.Show(Application.Current.MainWindow, $"未找到角色 海潮{m_startIndex:D4}"); var e = m_subList.FirstOrDefault(o => m_previous < o.Index && o.AccountInfo.GetBuildingInfo(WlyBuildingType.主城).Level < 130); if (e != null) { WlyUtilityBiz.Login(e); m_previous = e.Index; return; } return; } WlyUtilityBiz.Login(entity); m_previous = entity.Index; }
/// <summary> /// 挂机线程 /// </summary> private void AutoPlayThread() { m_run = true; m_final = true; m_isDevelop = false; var errorCount = 0; // 最外层死循环,进程守护 while (m_run) { try { // 登录 OnDescriptionChanged($"开始登录 {Account}"); DMGuid = string.Empty; WlyUtilityBiz.Login(this); // 绑定游戏窗口 BindGameWnd(); InternalAfterLogin(); // 登录成功,等待登录完成 OnDescriptionChanged("等待加载完成"); WlyViewMgr.GoTo(DMGuid, WlyViewType.场景_主界面, TimeSpan.FromSeconds(2)); // 开始挂机 m_aliveTime = DateTime.Now; while (m_run) { if (DMService.Instance.GetWindowState(DMGuid, WndHwnd, 0) == 0) { WxLog.Error($"WlyEntity.AutoPlayThread 游戏窗口不存在"); break; } WlyTaskRunner runner = null; // 检测是否有可以运行的日常任务 if (m_dailyList.Any() && (m_dailyList.First().StartTime < DateTime.Now)) { runner = m_dailyList.First(); OnDescriptionChanged(runner.Task.MainTitle); CurrentRunner = runner; var info = runner.Task.Run(this); WxLog.Debug($"WlyEntity.AutoPlayThread Name <{this}> Run <{runner.Task}> Result <{info}>"); // 无论结果,先进行保存 SaveTaskInfo(info); RemoveTaskRunner(runner); if (!info.IsComplete) { // 未完成的任务重新加入,等待下一次运行 AddTask(runner.Task, info.NextRunTime); } m_aliveTime = DateTime.Now; continue; } // 检测是否有可以运行的主线任务 runner = m_mainList.FirstOrDefault(o => o.StartTime < DateTime.Now); if (runner != null) { OnDescriptionChanged(runner.Task.MainTitle); CurrentRunner = runner; var info = runner.Task.Run(this); // 无论结果,先进行保存 SaveTaskInfo(info); RemoveTaskRunner(runner); if (!info.IsComplete) { // 未完成的任务重新加入,等待下一次运行 AddTask(runner.Task, info.NextRunTime); } m_aliveTime = DateTime.Now; continue; } CurrentRunner = null; // 运行空闲任务 InternalBackupWorkThread(); // 超时重启 if (DateTime.Now - m_aliveTime > m_restartInterval) { break; } } while (m_finalList.Any(o => o.StartTime < DateTime.Now)) { var runner = m_finalList.FirstOrDefault(o => o.StartTime < DateTime.Now); if (runner == null) { break; } OnDescriptionChanged(runner.Task.MainTitle); CurrentRunner = runner; var info = runner.Task.Run(this); WxLog.Debug($"WlyEntity.AutoPlayThread Name <{this}> Run <{runner.Task}> Result <{info}>"); // 无论结果,先进行保存 SaveTaskInfo(info); m_finalList.Remove(runner); if (!info.IsComplete) { // 未完成的任务重新加入,等待下一次运行 AddTask(runner.Task, info.NextRunTime); } m_aliveTime = DateTime.Now; } m_final = false; } catch (InvalidOperationException ex) { WxLog.Error($"WlyEntity.InternalBackupWorkThread Error {ex}"); errorCount++; InternalHandleError(errorCount); //CaptureError(ex); } catch (Exception ex) { WxLog.Error($"WlyEntity.AutoPlayThread Error <{ex}>"); } finally { CloseProcess(); } } WxLog.Debug($"WlyEntity.AutoPlayThread Stopped, Hwnd <{WndHwnd}>, Run <{Run}>"); OnStopped(); }