GameAssistDlg.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. // GameAssistDlg.cpp : 实现文件
  2. //
  3. #include "stdafx.h"
  4. #include "GameAssist.h"
  5. #include "GameAssistDlg.h"
  6. //#include "VideoDXGICaptor.h"
  7. #include "MouseAssist.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #endif
  11. VOID DebugLog(CHAR* pszStr, ...)
  12. {
  13. char szData[MAX_PATH] = { 0 };
  14. _stprintf_s(szData, _T("%s %s "), _T("[GameAssist] "), CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S")).GetString());
  15. int len = strlen(szData);
  16. va_list args;
  17. va_start(args, pszStr);
  18. _vsnprintf_s(szData + len, MAX_PATH - len, MAX_PATH - len, pszStr, args);
  19. va_end(args);
  20. strcat_s(szData, "\n");
  21. OutputDebugStringA(szData);
  22. }
  23. BOOL FindNPC(HWND hWnd, LPCSTR lpszNPC)
  24. {
  25. CRect rc;
  26. //// 打开世界地图;
  27. GAssist::SendKey(hWnd, VK_TAB); Sleep(500 + rand() % 200);
  28. if (!GAssist::GetImgMatchtemplate(hWnd, GAssist::g_strAppdir + _T("img\\寻路窗口.bmp"), rc))
  29. return FALSE;
  30. //// 单击寻路窗口;
  31. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2 + rand() % 2, (rc.top + rc.bottom) / 2 + rand() % 2)); Sleep(500 + rand() % 200);
  32. //// 设置剪切板:职业大挑战;
  33. GAssist::SetClipboardString(lpszNPC); Sleep(200 + rand() % 200);
  34. //// Ctrl+V
  35. GAssist::SendKey(hWnd, 0x56, TRUE); Sleep(300 + rand() % 200);
  36. // 先移动到目标后,才能实现单击;
  37. GAssist::MouseMove(hWnd, CPoint((rc.right + rc.left) / 2 + 5 + rand() % 2, (rc.top + rc.bottom) / 2 + 60 + rand() % 2)); Sleep(200 + rand() % 100);
  38. //// 寻路窗口往下50就是目标;
  39. GAssist::MouseDbClick(hWnd, CPoint((rc.right + rc.left) / 2 + 5 + rand() % 2, (rc.top + rc.bottom) / 2 + 60 + rand() % 2)); Sleep(200 + rand() % 100);
  40. //// 退出世界地址;
  41. GAssist::SendKey(hWnd, VK_TAB); Sleep(200 + rand() % 50);
  42. // 问题:返回TRUE并不表示到寻路到NPC;
  43. // 是否成功寻路到NPC要对NPC人物进向模板匹配或与NPC对话框模板匹配
  44. return TRUE;
  45. }
  46. BOOL ClickSetup(HWND hWnd, LPCSTR lpszTemplateImage)
  47. {
  48. CRect rc;
  49. TCHAR szTemplateImage[MAX_PATH] = { 0 };
  50. // 先截图;
  51. GAssist::SaveHwndToBmpFile(hWnd, GAssist::g_strAppdir + _T("Game.bmp"));
  52. _stprintf_s(szTemplateImage, _T("%s%s"),GAssist::g_strAppdir.c_str(), lpszTemplateImage);
  53. if (GAssist::GetImgMatchtemplate(GAssist::g_strAppdir + _T("Game.bmp"), szTemplateImage, rc)) {
  54. // 找到匹配的模块;
  55. GAssist::MouseMove(hWnd, CPoint(rc.left + rand() % 10, rc.top + rand() % 10));
  56. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 3), TRUE);
  57. Sleep(200 + rand() % 50);// 进入孤独洞要时间切换地图;
  58. // 单击目标后,要往移走鼠标,防止下面匹配的时候被鼠标挡住;
  59. GAssist::MouseMove(hWnd, CPoint(rc.left + 20 + rand() % 10, rc.top + 30 + rand() % 10));
  60. Sleep(300 + rand() % 300);// 进入孤独洞要时间切换地图;
  61. DebugLog(_T("找到目标并单击成功"));
  62. return TRUE;
  63. }
  64. return FALSE;
  65. }
  66. // 用于应用程序“关于”菜单项的 CAboutDlg 对话框
  67. class CAboutDlg : public CDialog
  68. {
  69. public:
  70. CAboutDlg();
  71. // 对话框数据
  72. enum { IDD = IDD_ABOUTBOX };
  73. protected:
  74. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
  75. // 实现
  76. protected:
  77. DECLARE_MESSAGE_MAP()
  78. };
  79. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  80. {
  81. }
  82. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  83. {
  84. CDialog::DoDataExchange(pDX);
  85. }
  86. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  87. END_MESSAGE_MAP()
  88. // CGameAssistDlg 对话框
  89. CGameAssistDlg::CGameAssistDlg(CWnd* pParent /*=NULL*/)
  90. : CDialog(CGameAssistDlg::IDD, pParent)
  91. {
  92. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  93. }
  94. void CGameAssistDlg::DoDataExchange(CDataExchange* pDX)
  95. {
  96. CDialog::DoDataExchange(pDX);
  97. }
  98. BEGIN_MESSAGE_MAP(CGameAssistDlg, CDialog)
  99. ON_WM_SYSCOMMAND()
  100. ON_WM_PAINT()
  101. ON_WM_QUERYDRAGICON()
  102. //}}AFX_MSG_MAP
  103. ON_BN_CLICKED(BTN_OPENGAME, &CGameAssistDlg::OnBnClickedOpengame)
  104. ON_BN_CLICKED(IDC_BUTTON2, &CGameAssistDlg::OnBnClickedButton2)
  105. ON_BN_CLICKED(IDC_BUTTON3, &CGameAssistDlg::OnBnClickedButton3)
  106. ON_BN_CLICKED(IDC_BUTTON4, &CGameAssistDlg::OnBnClickedButton4)
  107. ON_BN_CLICKED(IDC_BUTTON5, &CGameAssistDlg::OnBnClickedButton5)
  108. ON_BN_CLICKED(IDC_BUTTON6, &CGameAssistDlg::OnBnClickedButton6)
  109. END_MESSAGE_MAP()
  110. // CGameAssistDlg 消息处理程序
  111. BOOL CGameAssistDlg::OnInitDialog()
  112. {
  113. CDialog::OnInitDialog();
  114. // 将“关于...”菜单项添加到系统菜单中。
  115. // IDM_ABOUTBOX 必须在系统命令范围内。
  116. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  117. ASSERT(IDM_ABOUTBOX < 0xF000);
  118. CMenu* pSysMenu = GetSystemMenu(FALSE);
  119. if (pSysMenu != NULL)
  120. {
  121. BOOL bNameValid;
  122. CString strAboutMenu;
  123. bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
  124. ASSERT(bNameValid);
  125. if (!strAboutMenu.IsEmpty())
  126. {
  127. pSysMenu->AppendMenu(MF_SEPARATOR);
  128. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  129. }
  130. }
  131. // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
  132. // 执行此操作
  133. SetIcon(m_hIcon, TRUE); // 设置大图标
  134. SetIcon(m_hIcon, FALSE); // 设置小图标
  135. // TODO: 在此添加额外的初始化代码
  136. GAssist::Init();
  137. return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
  138. }
  139. void CGameAssistDlg::OnSysCommand(UINT nID, LPARAM lParam)
  140. {
  141. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  142. {
  143. CAboutDlg dlgAbout;
  144. dlgAbout.DoModal();
  145. }
  146. else
  147. {
  148. CDialog::OnSysCommand(nID, lParam);
  149. }
  150. }
  151. // 如果向对话框添加最小化按钮,则需要下面的代码
  152. // 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序,
  153. // 这将由框架自动完成。
  154. void CGameAssistDlg::OnPaint()
  155. {
  156. if (IsIconic())
  157. {
  158. CPaintDC dc(this); // 用于绘制的设备上下文
  159. SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
  160. // 使图标在工作区矩形中居中
  161. int cxIcon = GetSystemMetrics(SM_CXICON);
  162. int cyIcon = GetSystemMetrics(SM_CYICON);
  163. CRect rect;
  164. GetClientRect(&rect);
  165. int x = (rect.Width() - cxIcon + 1) / 2;
  166. int y = (rect.Height() - cyIcon + 1) / 2;
  167. // 绘制图标
  168. dc.DrawIcon(x, y, m_hIcon);
  169. }
  170. else
  171. {
  172. CDialog::OnPaint();
  173. }
  174. }
  175. //当用户拖动最小化窗口时系统调用此函数取得光标
  176. //显示。
  177. HCURSOR CGameAssistDlg::OnQueryDragIcon()
  178. {
  179. return static_cast<HCURSOR>(m_hIcon);
  180. }
  181. void CGameAssistDlg::OnBnClickedOpengame()
  182. {
  183. #if 1 // 获取游戏标题;
  184. DWORD dwPid = GAssist::GetProcessId();
  185. HWND hProWnd = GAssist::GetProMainHwnd(dwPid);
  186. //HWND hProWnd = GAssist::GetProMainHwnd(5824);
  187. TCHAR szWinText[MAX_PATH] = { 0 };
  188. ::GetWindowText(hProWnd, szWinText, MAX_PATH);
  189. #if 1
  190. Sleep(1000);
  191. m_mouseAssist.BindWnd(hProWnd, PT_TYPE::WINDOW_POINT);
  192. m_mouseAssist.MoveTo(205, 150);
  193. Sleep(1000);
  194. m_mouseAssist.MoveTo(250, 250);
  195. Sleep(1000);
  196. m_mouseAssist.MoveTo(350, 350);
  197. Sleep(1000);
  198. m_mouseAssist.MoveTo(10, 470);
  199. m_mouseAssist.LeftClick();
  200. /*GAssist::MouseMove(hProWnd, CPoint(205,150));
  201. Sleep(2000);
  202. GAssist::MouseMove(hProWnd, CPoint(100,100), CPoint(250,250));
  203. Sleep(2000);
  204. GAssist::MouseMove(hProWnd, CPoint(100,100), CPoint(350,350));*/
  205. return;
  206. #endif
  207. if (0)
  208. {
  209. Sleep(1000);
  210. GAssist::MouseClick(hProWnd, CPoint(205, 150));
  211. Sleep(1000);
  212. GAssist::MouseClick(hProWnd, CPoint(235, 150));
  213. Sleep(1000);
  214. GAssist::MouseClick(hProWnd, CPoint(275, 150));
  215. }
  216. if (0)
  217. {
  218. Sleep(1000);
  219. ::SetForegroundWindow(hProWnd);
  220. GAssist::DragMouse(hProWnd, CPoint(173, 192), CPoint(295, 190));
  221. }
  222. if (0) {
  223. GAssist::MouseDbClick(hProWnd, CPoint(476, 158));
  224. }
  225. if (0)
  226. {
  227. GAssist::SendKey(hProWnd, VK_TAB);
  228. }
  229. //RECT rc = {0,0,500,500};
  230. //HBITMAP hb = GAssist::CopyDC2Bitmap(hProWnd, &rc);
  231. //GAssist::SaveBitmap(hb, "1.bmp");
  232. //GAssist::SaveHwndToBmpFile(hProWnd, "2.bmp");
  233. return;
  234. #endif
  235. // TODO: 在此添加控件通知处理程序代码
  236. if (!PathFileExists(GAssist::g_szGameApp))
  237. {
  238. MessageBox("游戏程序不存在", "温馨提示");
  239. return;
  240. }
  241. // 设置辅助程序工作目录为游戏目录;
  242. //SetCurrentDirectory(_T("E:\\dhsh\\shdata\\"));
  243. SetCurrentDirectory(_T("D:\\tools\\dhsh\\shdata\\"));
  244. #if 1
  245. ShellExecute(NULL, "open", GAssist::g_szGameApp, NULL, NULL, SW_SHOWNORMAL);//SW_HIDE无用,因为会自动结;
  246. Sleep(500); // Main.exe设置了陷阱(自己再开启了一个进程,结束上一个进程),需要等5秒;
  247. #else
  248. SHELLEXECUTEINFO stuExecInfo = { 0 };
  249. DWORD dwExitCode = STILL_ACTIVE;
  250. //CString strCommandLine = _T("open");
  251. stuExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
  252. stuExecInfo.lpFile = GAssist::g_szGamePath;
  253. stuExecInfo.lpParameters = "open";
  254. stuExecInfo.nShow = SW_SHOWNORMAL;
  255. stuExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
  256. if (!ShellExecuteEx(&stuExecInfo))
  257. {
  258. DWORD dwError = GetLastError();
  259. CString strError = _T("");
  260. strError.Format(_T("执行ShellExecuteEx失败,错误码:%d"), dwError);
  261. AfxMessageBox(strError);
  262. return;
  263. }
  264. HANDLE hProcess = stuExecInfo.hProcess;
  265. if (hProcess != NULL)
  266. {
  267. WaitForSingleObject(hProcess, INFINITE);
  268. CloseHandle(hProcess);
  269. }
  270. #endif
  271. DWORD dwPID = GAssist::FindProcess(_T("Main.exe"));
  272. #if 1
  273. EnumWindows(GAssist::EnumChildWindowCallBack, dwPID);
  274. if (GAssist::g_vtGameHwnd.size())
  275. {
  276. GAssist::GameHwnd* gp = NULL;
  277. GAssist::GameHwnd* gbmin = NULL;
  278. GAssist::GameHwnd* gbentry = NULL;
  279. for (std::vector<GAssist::GameHwnd>::iterator it = GAssist::g_vtGameHwnd.begin(); it != GAssist::g_vtGameHwnd.end(); it++)
  280. {
  281. if (_tcsicmp(it->strWinText.c_str(), _T("最小化")) == 0)
  282. {
  283. gbmin = &*it;
  284. }
  285. if (_tcsicmp(it->strWinText.c_str(), _T("大话水浒")) == 0)
  286. {
  287. gp = &*it;
  288. }
  289. if (_tcsicmp(it->strWinText.c_str(), _T("进入游戏")) == 0)
  290. {
  291. gbentry = &*it;
  292. }
  293. }
  294. if (gp && gbentry && gbmin)
  295. {
  296. //::SendMessage(gp->hwnd, WM_LBUTTONDOWN, (WPARAM)gb->dwId, 0);
  297. //::SendMessage(gp->hwnd, WM_LBUTTONUP, (WPARAM)gb->dwId, 0);
  298. // 发送点击事件;
  299. // 先最小化;
  300. ::SendMessage(gp->hwnd, WM_COMMAND, gbmin->dwId, NULL);
  301. // 再进入;
  302. ::SendMessage(gp->hwnd, WM_COMMAND, gbentry->dwId, NULL);
  303. Sleep(1500);
  304. dwPID = GAssist::GetProcessId();
  305. if (dwPID)
  306. {
  307. GAssist::g_vtGameHwnd.clear();
  308. EnumWindows(GAssist::EnumChildWindowCallBack, dwPID);
  309. HWND hwnd = GAssist::GetProMainHwnd(dwPID);
  310. if (hwnd)
  311. {
  312. TCHAR szName[MAX_PATH] = { 0 };
  313. ::GetWindowText(hwnd, szName, MAX_PATH);
  314. CRect rc;
  315. ::GetWindowRect(hwnd, &rc);
  316. TCHAR szLogMsg[MAX_PATH] = { 0 };
  317. _stprintf_s(szLogMsg, _T("窗口标题:%s, [%d,%d, %d,%d], width=%d, height=%d\n"), szName, rc.top, rc.left, rc.right, rc.bottom, rc.Width(), rc.Height());
  318. OutputDebugString(szLogMsg);
  319. if (1)
  320. { // 800x600
  321. // 发送按钮消息;进入游戏;
  322. GAssist::MouseClick(hwnd, 585, 116);
  323. // 发送按钮消息;下一步;
  324. GAssist::MouseClick(hwnd, 536, 481);
  325. // 发送按钮消息;电信一区;
  326. GAssist::MouseClick(hwnd, 229, 342);
  327. // 发送按钮消息;忘忧谷;
  328. GAssist::MouseClick(hwnd, 335, 244);
  329. // 发送按钮消息;下一步;
  330. GAssist::MouseClick(hwnd, 559, 516);
  331. }
  332. else
  333. {
  334. // 640x480
  335. // 发送按钮消息;进入游戏;
  336. GAssist::MouseClick(hwnd, 440, 75);
  337. // 发送按钮消息;下一步;
  338. GAssist::MouseClick(hwnd, 468, 454);
  339. // 发送按钮消息;电信一区;
  340. GAssist::MouseClick(hwnd, 165, 241);
  341. // 发送按钮消息;忘忧谷;
  342. GAssist::MouseClick(hwnd, 289, 195);
  343. // 发送按钮消息;下一步;
  344. GAssist::MouseClick(hwnd, 494, 469);
  345. }
  346. }
  347. }
  348. }
  349. }
  350. #endif
  351. }
  352. void CGameAssistDlg::OnBnClickedButton2()
  353. {
  354. // TODO: 在此添加控件通知处理程序代码
  355. // VideoDXGICaptor vdx;
  356. // if (vdx.Init())
  357. // {
  358. // INT len = 1024 * 1024 * 1024;
  359. // BYTE* pData = new BYTE[len];
  360. // vdx.CaptureImage(pData, len);
  361. // vdx.Deinit();
  362. // }
  363. DWORD dwPid = GAssist::GetProcessId();
  364. HWND hProWnd = GAssist::GetProMainHwnd(dwPid);
  365. // 截图;
  366. GAssist::SaveHwndToBmpFile(hProWnd, "Game.bmp");
  367. }
  368. void CGameAssistDlg::OnBnClickedButton3() // 镜妖;
  369. {
  370. // 获取进程句柄;
  371. DWORD dwPid = GAssist::GetProcessId();
  372. HWND hProWnd = GAssist::GetProMainHwnd(dwPid);
  373. if (GAssist::nGameWndType == GAssist::GW_SMALL)
  374. {
  375. //// 地图区域;
  376. //CRect rc(469,25,635,65);
  377. //// 判断当前地图;
  378. //if (GAssist::SaveBitmap(GAssist::CopyDC2Bitmap(hProWnd, rc), GAssist::g_strAppdir + _T("Game.bmp")))
  379. //{
  380. // if (GAssist::GetImgMatchtemplate(GAssist::g_strAppdir + _T("Game.bmp"), GAssist::g_strAppdir + _T("img\\地图\\应天府.bmp"), rc))
  381. // {
  382. // }
  383. // else if (GAssist::GetImgMatchtemplate(GAssist::g_strAppdir + _T("Game.bmp"), GAssist::g_strAppdir + _T("img\\地图\\应天府.bmp"), rc))
  384. // {
  385. // }
  386. //}
  387. CRect rc;
  388. //FIND_NPC(hProWnd, _T("臭美的小米"));
  389. Sleep(3000);
  390. // 与小米对话;
  391. //if (!GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\1-我帮您抓.bmp"), rc)) {
  392. // GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
  393. // Sleep(200);
  394. // // 判断是否还有对话,如果没有的话表明不是第一次进入;
  395. // if (GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\2-我这就去.bmp"), rc)) {
  396. // GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
  397. // Sleep(200);
  398. // // 2次对话;
  399. // if (GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\3-幸运镜妖.bmp"), rc)) {
  400. // GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
  401. // Sleep(200);
  402. // // 3次对话;
  403. // if (GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\3-我就选择它.bmp"), rc)) {
  404. // GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
  405. // Sleep(200);
  406. // }
  407. // }
  408. // }
  409. //
  410. //
  411. //}
  412. for (int i = 0; i < 20; i++)
  413. {
  414. // 进入贫民房;
  415. if (GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\镜妖1.bmp"), rc)) {
  416. GAssist::MouseMove(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
  417. GAssist::MouseMove(hProWnd, CPoint((rc.right + rc.left) / 2 - 1, (rc.top + rc.bottom) / 2 - 1));
  418. GAssist::MouseMove(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
  419. Sleep(200);
  420. if (GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\定位镜妖.bmp"), rc)) {
  421. GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
  422. Sleep(500);
  423. // 选择我要打你;
  424. if (GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\我来抓您的.bmp"), rc)) {
  425. GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
  426. Sleep(500);
  427. // 判断是否在战斗中;
  428. while (GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\头像.bmp"), rc)) {
  429. if (rc.left > 60)
  430. {
  431. GAssist::ShowLog(_T("战斗中"));
  432. GAssist::SendKey(hProWnd, 0x41, FALSE, TRUE);
  433. Sleep(3000);
  434. }
  435. else
  436. {
  437. GAssist::ShowLog(_T("非战斗"));
  438. break;
  439. }
  440. }
  441. }
  442. }
  443. }
  444. else {
  445. static int i = 0;
  446. if (i == 0)
  447. {
  448. GAssist::SendKey(hProWnd, VK_TAB); Sleep(500);
  449. GAssist::MouseClick(hProWnd, CPoint(225, 305));
  450. GAssist::SendKey(hProWnd, VK_TAB); Sleep(100);
  451. i++;
  452. }
  453. else if (i == 1)
  454. {
  455. GAssist::SendKey(hProWnd, VK_TAB); Sleep(500);
  456. GAssist::MouseClick(hProWnd, CPoint(300, 266));
  457. GAssist::SendKey(hProWnd, VK_TAB); Sleep(100);
  458. i++;
  459. }
  460. else if (i == 2)
  461. {
  462. GAssist::SendKey(hProWnd, VK_TAB); Sleep(500);
  463. GAssist::MouseClick(hProWnd, CPoint(175, 280));
  464. GAssist::SendKey(hProWnd, VK_TAB); Sleep(100);
  465. i = 0;
  466. }
  467. Sleep(2000);
  468. }
  469. }
  470. }
  471. else if (GAssist::nGameWndType == GAssist::GW_LARGE)
  472. {
  473. CRect rc(630, 25, 800, 65);
  474. if (GAssist::SaveBitmap(GAssist::CopyDC2Bitmap(hProWnd, rc), GAssist::g_strAppdir + _T("dt.bmp")))
  475. {
  476. }
  477. }
  478. }
  479. void CGameAssistDlg::OnBnClickedButton4() // 周六领礼物
  480. {
  481. // TODO: 在此添加控件通知处理程序代码
  482. }
  483. void CGameAssistDlg::OnBnClickedButton5() // 开宝箱;
  484. {
  485. HWND hProcessMainWnd = GAssist::GetProcessMainWnd();
  486. if (GAssist::nGameWndType == GAssist::GW_SMALL)
  487. {
  488. CRect rc;
  489. MouseAssist mouseAssist;
  490. mouseAssist.BindWnd(hProcessMainWnd, PT_TYPE::SCREEN_POINT);
  491. for (int i = 0; i < 50; i++)
  492. {
  493. if (!GAssist::GetImgMatchtemplate(hProcessMainWnd, GAssist::g_strAppdir + _T("img\\开宝箱\\应天府铁匠.bmp"), rc))
  494. {
  495. // 没找到,要将鼠标从目标中移走;并且要右击一次将目标的高亮状态取消;
  496. mouseAssist.SetCursorPos(rc.top + rand() % 5, rc.left + rand() % 5);
  497. mouseAssist.MoveTo(rc.top - rand() % 5, rc.left - rand() % 5);
  498. mouseAssist.RightClick();
  499. }
  500. else
  501. {
  502. GAssist::MouseClick(hProcessMainWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 5));
  503. Sleep(600 + rand() % 30);
  504. // 再移动下,会更高精度;
  505. mouseAssist.MoveTo(rc.top - rand() % 15, rc.left - rand() % 15);
  506. // 判断是否还有对话,如果没有的话表明不是第一次进入;
  507. if (GAssist::GetImgMatchtemplate(hProcessMainWnd, GAssist::g_strAppdir + _T("img\\开宝箱\\开宝箱.bmp"), rc)) {
  508. GAssist::MouseClick(hProcessMainWnd, CPoint((rc.right + rc.left) / 2 + rand() % 2, (rc.top + rc.bottom) / 2 + rand() % 2));
  509. Sleep(rand() % 200 + 190);
  510. // 然后移动出去;
  511. //GAssist::MouseMove(hProcessMainWnd, CPoint(rc.top - 50 - rand()%20, rc.left - 50 - rand() % 20));
  512. mouseAssist.SetCursorPos(rc.top + rand() % 5, rc.left + rand() % 5);
  513. mouseAssist.MoveToEx(rc.top, rc.left, rc.Width(), rc.Height());
  514. }
  515. }
  516. Sleep(600 + rand() % 300);
  517. }
  518. }
  519. }
  520. void CGameAssistDlg::OnBnClickedButton6() // 职业挑战;
  521. {
  522. CRect rc;
  523. DebugLog(_T("进入孤独洞========="));
  524. HWND hProWnd = GAssist::GetProcessMainWnd();
  525. //// 打开世界地图;
  526. GAssist::SendKey(hProWnd, VK_TAB); Sleep(500 + rand() % 200);
  527. if (!GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\寻路窗口.bmp"), rc))
  528. return;
  529. //// 单击寻路窗口;
  530. GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2 + rand() % 2, (rc.top + rc.bottom) / 2 + rand() % 2)); Sleep(500 + rand() % 200);
  531. //// 设置剪切板:职业大挑战;
  532. GAssist::SetClipboardString("职业训导大师"); Sleep(200 + rand() % 200);
  533. //// Ctrl+V
  534. GAssist::SendKey(hProWnd, 0x56, TRUE); Sleep(300 + rand() % 200);
  535. // 先移动到目标后,才能实现单击;
  536. GAssist::MouseMove(hProWnd, CPoint((rc.right + rc.left) / 2 + 5 + rand() % 2, (rc.top + rc.bottom) / 2 + 60 + rand() % 2)); Sleep(200 + rand() % 100);
  537. //// 寻路窗口往下50就是目标;
  538. GAssist::MouseDbClick(hProWnd, CPoint((rc.right + rc.left) / 2 + 5 + rand() % 2, (rc.top + rc.bottom) / 2 + 60 + rand() % 2)); Sleep(200 + rand() % 100);
  539. //// 退出世界地址;
  540. GAssist::SendKey(hProWnd, VK_TAB); Sleep(200 + rand() % 50);
  541. // 选择进入;
  542. BOOL bMatch = FALSE;
  543. int trySize = 20;
  544. // 我要挑战他们;
  545. while (!(bMatch = GAssist::GetImgMatchtemplate(GAssist::g_strAppdir + _T("Game.bmp"), GAssist::g_strAppdir + _T("img\\zyxdds-wytztm.bmp"), rc))) {
  546. Sleep(3000 + rand() % 500);
  547. // 截图;
  548. GAssist::SaveHwndToBmpFile(hProWnd, GAssist::g_strAppdir + _T("Game.bmp"));
  549. GAssist::MouseMove(hProWnd, CPoint(rc.left + rand()%10, rc.top+rand()%10));
  550. if (!trySize--) break;
  551. }
  552. if (bMatch) {
  553. GAssist::MouseMove(hProWnd, CPoint(rc.left, rc.top));
  554. // 单击:我要挑战他们;
  555. GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2), TRUE);
  556. Sleep(2000 + rand()%500 );// 等出图;
  557. // 移动一下;
  558. GAssist::MouseMove(hProWnd, CPoint(rc.left, rc.top));
  559. ::SetCursorPos(rc.left + rand()%6, rc.top + rand()%8);
  560. trySize = 5;
  561. bMatch = FALSE;
  562. // 再单击:我准备好了;
  563. GAssist::SaveHwndToBmpFile(hProWnd, GAssist::g_strAppdir + _T("Game.bmp"));
  564. while (!(bMatch = GAssist::GetImgMatchtemplate(GAssist::g_strAppdir + _T("Game.bmp"), GAssist::g_strAppdir + _T("img\\zyxdds-zbhl.bmp"), rc))) {
  565. GAssist::MouseMove(hProWnd, CPoint(rc.left + rand() % 20, rc.top + rand() % 20));
  566. Sleep(200 + rand()%200);//等进入地图;
  567. if (!trySize--) break;
  568. }
  569. if ( bMatch ) {
  570. GAssist::MouseMove(hProWnd, CPoint(rc.left + rand() % 10, rc.top + rand() % 10));
  571. GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 3), TRUE);
  572. Sleep(1500 + rand()%300);// 进入孤独洞要时间切换地图;
  573. DebugLog(_T("进入孤独洞1"));
  574. // 判断是否在孤独洞;
  575. GAssist::SaveHwndToBmpFile(hProWnd, GAssist::g_strAppdir + _T("Game.bmp"));
  576. if (GAssist::GetImgMatchtemplate(GAssist::g_strAppdir + _T("Game.bmp"), GAssist::g_strAppdir + _T("img\\gdd\\name.bmp"), rc)) {
  577. DebugLog(_T("进入孤独洞2"));
  578. char szName[11][32] = { "医师独侠","术士独侠","道士独侠","武师独侠","浪子独侠","剑客独侠","弓手独侠","禁卫独侠","墨者独侠","巫煞独侠","魂武独侠" };
  579. for (int i = 0; i < 10; i++)
  580. {
  581. if (FindNPC(hProWnd, szName[i]))
  582. {
  583. if (_tcscmp(szName[i], _T("医师独侠")) == 0)
  584. {
  585. Sleep(5500 + rand()%300); // 等你走到她面前;
  586. if (ClickSetup(hProWnd, "img\\jn-jk\\gdd\\xyy.bmp"))
  587. {
  588. // 选择技能:缚神诀;
  589. if (ClickSetup(hProWnd, "img\\jn-jk\\gdd\\fsj.bmp"))
  590. {
  591. if (!ClickSetup(hProWnd, "\\img\\jn-jk\\gdd\\qd.bmp"))
  592. break;
  593. Sleep(200+rand()%30);
  594. if (!ClickSetup(hProWnd, "\\img\\jn-jk\\gdd\\qd.bmp"))
  595. break;
  596. Sleep(100 + rand()%50);
  597. // 打6下;
  598. for (size_t i = 0; i < 5; i++)
  599. {
  600. // 缚神诀的快捷键是:F6
  601. GAssist::SendKey(hProWnd, VK_F6);
  602. Sleep(1600+rand()%300);
  603. }
  604. }
  605. }
  606. break;
  607. }
  608. else
  609. {
  610. }
  611. }
  612. Sleep(200 + rand()%300);
  613. DebugLog(_T("进入孤独洞2:%s"), szName[i]);
  614. }
  615. }
  616. }
  617. }
  618. }