GameAssistDlg.cpp 21 KB

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