GameAssistDlg.cpp 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776
  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. #define SRAND(a,b) (Sleep(rand()%(b-a)+a))
  13. std::map<std::string, POINT> g_mapZYNPC;
  14. BOOL IsWalkStop(HWND hWnd);
  15. CRect FindMatchIcon(HWND hWnd, LPCSTR lpszTemplateImage);
  16. void WorldMapPositioning(HWND hWnd, POINT ptMap);
  17. VOID DebugLog(CHAR* pszStr, ...)
  18. {
  19. char szData[MAX_PATH] = { 0 };
  20. _stprintf_s(szData, _T("%s %s "), _T("[GameAssist] "), CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S")).GetString());
  21. int len = strlen(szData);
  22. va_list args;
  23. va_start(args, pszStr);
  24. _vsnprintf_s(szData + len, MAX_PATH - len, MAX_PATH - len, pszStr, args);
  25. va_end(args);
  26. strcat_s(szData, "\n");
  27. OutputDebugStringA(szData);
  28. }
  29. void InitZYNPC()
  30. {
  31. // "医师独侠","术士独侠","道士独侠","武师独侠","浪子独侠","剑客独侠", "弓手独侠", "禁卫独侠", "墨者独侠", "巫煞独侠", "魂武独侠"
  32. g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("医师独侠"), { 0, 0 }));
  33. g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("术士独侠"), { 0, 0 }));
  34. g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("道士独侠"), { 0, 0 }));
  35. g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("武师独侠"), { 0, 0 }));
  36. g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("浪子独侠"), { 0, 0 }));
  37. g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("剑客独侠"), { 0, 0 }));
  38. g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("弓手独侠"), { 0, 0 }));
  39. g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("禁卫独侠"), { 0, 0 }));
  40. g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("墨者独侠"), { 0, 0 }));
  41. g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("巫煞独侠"), { 0, 0 }));
  42. g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("魂武独侠"), { 0, 0 }));
  43. }
  44. BOOL FindNPC(HWND hWnd, LPCSTR lpszNPC)
  45. {
  46. CRect rc;
  47. //// 打开世界地图;
  48. GAssist::SendKey(hWnd, VK_TAB); SRAND(500, 600);
  49. if (!GAssist::GetImgMatchtemplate(hWnd, GAssist::g_strAppdir + _T("img\\寻路窗口.bmp"), rc))
  50. return FALSE;
  51. //// 单击寻路窗口;
  52. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2 + rand() % 2, (rc.top + rc.bottom) / 2 + rand() % 2)); SRAND(500, 800);
  53. //// 设置剪切板:职业大挑战;
  54. GAssist::SetClipboardString(lpszNPC); SRAND(200, 500);
  55. //// Ctrl+V
  56. GAssist::SendKey(hWnd, 0x56, TRUE); SRAND(300, 500);
  57. // 先移动到目标后,才能实现单击;
  58. GAssist::MouseMove(hWnd, CPoint((rc.right + rc.left) / 2 + 5 + rand() % 2, (rc.top + rc.bottom) / 2 + 60 + rand() % 2)); SRAND(200, 300);
  59. //// 寻路窗口往下50就是目标;
  60. GAssist::MouseDbClick(hWnd, CPoint((rc.right + rc.left) / 2 + 5 + rand() % 2, (rc.top + rc.bottom) / 2 + 60 + rand() % 2)); SRAND(200, 300);
  61. //// 退出世界地址;
  62. GAssist::SendKey(hWnd, VK_TAB); SRAND(200, 300);
  63. // 直到停止走动为止;
  64. IsWalkStop(hWnd);
  65. // 遍历3次;
  66. BOOL bFind = FALSE;
  67. for (int i = 0; i < 3; i++)
  68. {
  69. Sleep(600);
  70. rc = FindMatchIcon(hWnd, "img\\对话框关闭按钮.bmp");
  71. if (!rc.IsRectEmpty() && !rc.IsRectNull())
  72. {
  73. bFind = TRUE;
  74. break;
  75. }
  76. }
  77. return bFind;
  78. }
  79. BOOL FindNPC(HWND hWnd, POINT ptMap, LPCTSTR lpszTemplate)
  80. {
  81. WorldMapPositioning(hWnd, ptMap);
  82. CRect rc = FindMatchIcon(hWnd, lpszTemplate);
  83. if (rc.IsRectEmpty() || rc.IsRectNull())
  84. return FALSE;
  85. // 找到目标,单击;
  86. GAssist::MouseMove(hWnd, CPoint(rc.left, rc.top));
  87. // 单击:我要挑战他们;
  88. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2), TRUE);
  89. SRAND(900, 1500);// 等对话框出现;
  90. return TRUE;
  91. }
  92. // 单击对话框里的步骤;
  93. BOOL ClickDlgSetup(HWND hWnd, LPCSTR lpszTemplateImage)
  94. {
  95. CRect rc = FindMatchIcon(hWnd, lpszTemplateImage);
  96. if (rc.IsRectEmpty() || rc.IsRectNull())
  97. return FALSE;
  98. // 单击目标;
  99. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 3), TRUE);
  100. SRAND(200, 300);
  101. // 单击目标后,要往移走鼠标,防止下面匹配的时候被鼠标挡住;
  102. GAssist::MouseMove(hWnd, CPoint(rc.top - RAND(5, 12), rc.left - RAND(5, 10))); // 移动到左上角;
  103. SRAND(300, 500);
  104. return TRUE;
  105. }
  106. CRect FindMatchIcon(HWND hWnd, LPCSTR lpszTemplateImage)
  107. {
  108. CRect rc;
  109. TCHAR szTemplateImage[MAX_PATH] = { 0 };
  110. ::ShowWindow(hWnd, SW_SHOWNORMAL);
  111. ::SetForegroundWindow(hWnd);
  112. // 先截图;
  113. DebugLog(_T("FindMatchIcon=%s"), lpszTemplateImage);
  114. GAssist::SaveHwndToBmpFile(hWnd, GAssist::g_strAppdir + _T("Game.bmp")); SRAND(200, 500);
  115. _stprintf_s(szTemplateImage, _T("%s%s"), GAssist::g_strAppdir.c_str(), lpszTemplateImage);
  116. if (GAssist::GetImgMatchtemplate(GAssist::g_strAppdir + _T("Game.bmp"), szTemplateImage, rc)) {
  117. // 找到匹配的模块;
  118. DebugLog(_T("====> 找到匹配目标:%s"), lpszTemplateImage);
  119. return rc;
  120. }
  121. rc.SetRectEmpty();
  122. DebugLog(_T("<==== 没找到匹配目标:%s"), lpszTemplateImage);
  123. return rc;
  124. }
  125. BOOL IsOnMap(HWND hWnd, LPCSTR lpszTemplateImage)
  126. {
  127. CRect rc = FindMatchIcon(hWnd, lpszTemplateImage);
  128. if (rc.IsRectEmpty() || rc.IsRectNull())
  129. return FALSE;
  130. return TRUE;
  131. }
  132. BOOL IsBattle(HWND hWnd)
  133. {
  134. CRect rc;
  135. BOOL bBattle = FALSE;
  136. SRAND(100, 200);
  137. if (GAssist::IsMatchIcon(hWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\非战斗中.bmp"), { 630, 25, 805, 45 }, rc)) {
  138. DebugLog(_T("Battle:非战斗中"));
  139. return FALSE;
  140. }
  141. DebugLog(_T("Battle:战斗中"));
  142. return TRUE;
  143. }
  144. // nAttackNPCType 0=镜妖; 1=职业挑战
  145. //
  146. BOOL IsWattingAttack(HWND hWnd, int nAttackNPCType)
  147. {
  148. CRect rc;
  149. BOOL bIsAttack = FALSE;
  150. switch (nAttackNPCType)
  151. {
  152. case 0:
  153. { // 将鼠标移动到指定位置;
  154. DebugLog(_T("IsWattingAttack:镜妖中……"));
  155. POINT ptDest = { 20, 50 }; // 左上角;
  156. GAssist::MouseMove(hWnd, ptDest);
  157. if (GAssist::IsMatchIcon(hWnd, GAssist::g_strAppdir + _T("img\\我方攻击.bmp"), { 0, 50, 60, 115 }, rc)) {
  158. DebugLog(_T("IsWattingAttack:我方攻击"));
  159. bIsAttack = TRUE;
  160. }
  161. break;
  162. }
  163. case 1:
  164. {
  165. // 将鼠标移动到指定位置;
  166. DebugLog(_T("IsWattingAttack:职业挑战中……"));// 要求角色:自定全黑头像;
  167. //POINT ptDest = { 625, 28 }; // 左上角;
  168. //GAssist::MouseMove(hWnd, ptDest);
  169. if (!GAssist::IsMatchIcon(hWnd, GAssist::g_strAppdir + _T("img\\战斗中.bmp"), { 600, 25, 655, 80 }, rc)) {
  170. DebugLog(_T("IsWattingAttack:我方攻击"));
  171. bIsAttack = TRUE;
  172. }
  173. break;
  174. }
  175. default:
  176. break;
  177. }
  178. return bIsAttack;
  179. }
  180. void BattleOnece(HWND hWnd, BOOL bHasSummoner)
  181. {
  182. BOOL bBattle = FALSE;
  183. if (IsBattle(hWnd))
  184. {
  185. SRAND(300, 500);
  186. // 是否我方攻击;
  187. if (IsWattingAttack(hWnd, 0)) {
  188. // 人物固定F1
  189. // 根据角色选择技能;
  190. GAssist::SendKey(hWnd, VK_F1);
  191. SRAND(200, 300);
  192. // 打镜妖喽罗;
  193. GAssist::MouseClick(hWnd, CPoint(290 - 3, 140 - 20));
  194. //GAssist::MouseMove(hWnd, CPoint(220 - 5, 180 - 10));// 打主镜妖;
  195. SRAND(100, 200);
  196. }
  197. }
  198. else
  199. {
  200. // 非战斗中,是否在贫民房中;
  201. if (!IsOnMap(hWnd, _T("img\\地图\\贫民房.bmp")))
  202. {
  203. // 找小米;
  204. CRect rc;
  205. if (!FindNPC(hWnd, "臭美的小米"))
  206. return;
  207. // 选择进入;
  208. BOOL bMatch = FALSE;
  209. int trySize = 20;
  210. // 我要挑战他们;
  211. while (!(bMatch = ClickDlgSetup(hWnd, _T("img\\活动\\镜妖\\1-我帮您抓.bmp")))) {
  212. SRAND(800, 1200);
  213. if (!trySize--) break;
  214. }
  215. if (bMatch) {
  216. GAssist::MouseMove(hWnd, CPoint(rc.left, rc.top));
  217. // 单击:我要挑战他们;
  218. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2), TRUE);
  219. SRAND(1000, 1500);// 等出图;
  220. // 移动一下;
  221. GAssist::MouseMove(hWnd, CPoint(rc.left, rc.top));
  222. ::SetCursorPos(rc.left + rand() % 6, rc.top + rand() % 8);
  223. // 是否第一次进入地图;
  224. if (ClickDlgSetup(hWnd, _T("img\\活动\\镜妖\\2-我这就去.bmp")))
  225. {
  226. SRAND(600, 1200);
  227. if (ClickDlgSetup(hWnd, _T("img\\活动\\镜妖\\3-战意镜妖.bmp")))
  228. {
  229. SRAND(600, 1800);
  230. if ((bMatch = ClickDlgSetup(hWnd, _T("img\\活动\\镜妖\\4-我就选择它.bmp"))))
  231. {
  232. SRAND(800, 1800);
  233. }
  234. }
  235. }
  236. }
  237. }
  238. else
  239. {
  240. // 找到镜妖;
  241. CRect rc;
  242. POINT spt[4] = { { 260, 360 }, { 300,390}, { 390, 350}, { 280,300 } };
  243. for (int i = 0; !GAssist::GetImgMatchtemplate(hWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\镜妖3.bmp"), rc); i++)
  244. {
  245. // 打开世界地图;
  246. GAssist::SendKey(hWnd, VK_TAB); SRAND(200, 300);
  247. // 选择坐标点;
  248. GAssist::MouseClick(hWnd, spt[i % 4]);
  249. // 退出世界地图;
  250. GAssist::SendKey(hWnd, VK_TAB); SRAND(500, 900);
  251. if (i > 10) {
  252. DebugLog(_T("未找到镜妖+10"));
  253. break;
  254. }
  255. }
  256. // 找到镜妖;
  257. GAssist::MouseMove(hWnd, CPoint(rc.left + rand() % 10, rc.top + rand() % 10));
  258. DebugLog(_T("移动鼠标"));
  259. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 3), TRUE);
  260. SRAND(300, 600);
  261. // 单击目标后,要往移走鼠标,防止下面匹配的时候被鼠标挡住;
  262. GAssist::MouseMove(hWnd, CPoint(rc.right + RAND(5, 12), rc.bottom + RAND(5, 10)));
  263. SRAND(200, 500);
  264. DebugLog(_T("找到目标并单击成功:%s"));
  265. // 我来抓你;
  266. if (GAssist::GetImgMatchtemplate(hWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\我来抓您的.bmp"), rc)) {
  267. // 找到匹配的模块;
  268. GAssist::MouseMove(hWnd, CPoint(rc.left + rand() % 10, rc.top + rand() % 10));
  269. DebugLog(_T("我来抓你:移动鼠标"));
  270. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 3), TRUE);
  271. SRAND(800, 1500);
  272. DebugLog(_T("我来抓你:找到目标并单击成功:%s"));
  273. }
  274. }
  275. }
  276. }
  277. // 与镜妖战斗;
  278. void BattleJY(HWND hWnd, BOOL bHasSummoner, int nZJType, BOOL bAggressiveSkill)
  279. {
  280. BOOL bFirstAttack = TRUE;
  281. while (IsBattle(hWnd)) { // 是否在战斗中;
  282. // 是否我方攻击;
  283. while (IsWattingAttack(hWnd, 0)) { // Bug:如果被镜妖打死了,无法中断;
  284. DebugLog(_T("BattleJY:我方攻击……"));
  285. if (bFirstAttack)
  286. {
  287. SRAND(250, 300);
  288. DebugLog(_T("BattleJY:第一次攻击……"));
  289. // 根据角色选择技能;
  290. GAssist::SendKey(hWnd, VK_F1);
  291. SRAND(300, 350);
  292. if (bAggressiveSkill) // 打镜妖喽罗;
  293. {
  294. GAssist::MouseClick(hWnd, CPoint(290 - 3, 140 - 20));
  295. //GAssist::MouseMove(hWnd, CPoint(220 - 5, 180 - 10));// 打主镜妖;
  296. SRAND(350, 500);
  297. }
  298. if (bHasSummoner) {
  299. CRect rc;
  300. // 召唤兽技能;
  301. DebugLog(_T("BattleJY:召唤兽技能选择"));
  302. // 选择重击;
  303. if (nZJType) {
  304. SRAND(150, 350);
  305. GAssist::SendKey(hWnd, VK_S, FALSE, TRUE);
  306. DebugLog(_T("BattleJY:召唤兽技能选择:%d"), nZJType);
  307. if (GAssist::GetImgMatchtemplate(hWnd, nZJType == 1 ? GAssist::g_strAppdir + _T("img\\活动\\镜妖\\重击.bmp") : GAssist::g_strAppdir + _T("img\\活动\\镜妖\\重击2.bmp"), rc))
  308. {
  309. SRAND(150, 300);
  310. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 3), TRUE);
  311. }
  312. }
  313. SRAND(300, 500);
  314. GAssist::MouseMove(hWnd, CPoint(290 - 3, 140 - 15));
  315. GAssist::MouseClick(hWnd, CPoint(290 - 3, 140 - 20));
  316. }
  317. bFirstAttack = FALSE;
  318. }
  319. else
  320. {
  321. DebugLog(_T("BattleJY:不是第一次攻击……"));
  322. GAssist::SendKey(hWnd, VK_A, FALSE, TRUE);
  323. SRAND(80, 100);
  324. if (bFirstAttack) {
  325. GAssist::SendKey(hWnd, VK_A, FALSE, TRUE);
  326. SRAND(80, 120);
  327. }
  328. }
  329. }
  330. SRAND(500, 850);
  331. }
  332. // 非战斗中,是否在贫民房中;
  333. if (!IsOnMap(hWnd, _T("img\\地图\\贫民房.bmp"))) {
  334. // 找小米;
  335. CRect rc;
  336. if (!FindNPC(hWnd, "臭美的小米"))
  337. return;
  338. // 选择进入;
  339. BOOL bMatch = FALSE;
  340. int trySize = 15;
  341. // 我要挑战他们;
  342. while (!(bMatch = ClickDlgSetup(hWnd, _T("img\\活动\\镜妖\\1-我帮您抓.bmp")))) {
  343. SRAND(800, 1200);
  344. if (!trySize--) break;
  345. }
  346. if (bMatch) {
  347. GAssist::MouseMove(hWnd, CPoint(rc.left, rc.top));
  348. // 单击:我要挑战他们;
  349. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2), TRUE);
  350. SRAND(1000, 1500);// 等出图;
  351. // 移动一下;
  352. GAssist::MouseMove(hWnd, CPoint(rc.left, rc.top));
  353. ::SetCursorPos(rc.left + rand() % 6, rc.top + rand() % 8);
  354. // 是否第一次进入地图;
  355. if (ClickDlgSetup(hWnd, _T("img\\活动\\镜妖\\2-我这就去.bmp")))
  356. {
  357. SRAND(600, 1200);
  358. if (ClickDlgSetup(hWnd, _T("img\\活动\\镜妖\\3-战意镜妖.bmp")))
  359. {
  360. SRAND(600, 1800);
  361. if ((bMatch = ClickDlgSetup(hWnd, _T("img\\活动\\镜妖\\4-我就选择它.bmp"))))
  362. {
  363. SRAND(800, 1800);
  364. }
  365. }
  366. }
  367. }
  368. }
  369. else
  370. {
  371. // 找到镜妖;
  372. CRect rc;
  373. POINT spt[4] = { { 250, 335 }, { 310,360}, { 385, 315}, { 280,295 } };
  374. for (int i = 0; !GAssist::GetImgMatchtemplate(hWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\镜妖1.bmp"), rc); i++)
  375. {
  376. // 打开世界地图;
  377. GAssist::SendKey(hWnd, VK_TAB); SRAND(200, 300);
  378. // 选择坐标点;
  379. GAssist::MouseClick(hWnd, spt[i % 4]);
  380. // 退出世界地图;
  381. GAssist::SendKey(hWnd, VK_TAB); SRAND(500, 900);
  382. // 等待跑完成;
  383. //SRAND(600, 800);
  384. IsWalkStop(hWnd);
  385. if (i > 10) {
  386. DebugLog(_T("未找到镜妖+10"));
  387. break;
  388. }
  389. }
  390. // 找到镜妖;
  391. GAssist::MouseMove(hWnd, CPoint(rc.left + rand() % 10, rc.top + rand() % 10));
  392. DebugLog(_T("移动鼠标"));
  393. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 3), TRUE);
  394. SRAND(390, 600);
  395. // 单击目标后,要往移走鼠标,防止下面匹配的时候被鼠标挡住;
  396. GAssist::MouseMove(hWnd, CPoint(rc.right + RAND(10, 20), rc.bottom + RAND(10, 20)));
  397. SRAND(300, 500);
  398. DebugLog(_T("找到目标并单击成功:%s"));
  399. // 我来抓你;
  400. if (GAssist::GetImgMatchtemplate(hWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\我来抓您的.bmp"), rc)) {
  401. // 找到匹配的模块;
  402. SRAND(200, 300);
  403. //GAssist::MouseMove(hWnd, CPoint(rc.left + rand() % 10, rc.top + rand() % 10));
  404. DebugLog(_T("我来抓你:移动鼠标"));
  405. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 3), TRUE);
  406. SRAND(1000, 1500);
  407. DebugLog(_T("我来抓你:找到目标并单击成功:%s"));
  408. }
  409. }
  410. }
  411. void BattleJY2(HWND hWnd, BOOL bSummoner)
  412. {
  413. if (!IsOnMap(hWnd, _T("img\\地图\\贫民房.bmp"))) {
  414. // 找小米;
  415. CRect rc;
  416. if (!FindNPC(hWnd, "臭美的小米"))
  417. return;
  418. // 选择进入;
  419. BOOL bMatch = FALSE;
  420. int trySize = 20;
  421. // 我要挑战他们;
  422. while (!(bMatch = ClickDlgSetup(hWnd, _T("img\\活动\\镜妖\\1-我帮您抓.bmp")))) {
  423. SRAND(800, 1200);
  424. if (!trySize--) break;
  425. }
  426. if (bMatch) {
  427. GAssist::MouseMove(hWnd, CPoint(rc.left, rc.top));
  428. // 单击:我要挑战他们;
  429. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2), TRUE);
  430. SRAND(1000, 1500);// 等出图;
  431. // 移动一下;
  432. GAssist::MouseMove(hWnd, CPoint(rc.left, rc.top));
  433. ::SetCursorPos(rc.left + rand() % 6, rc.top + rand() % 8);
  434. // 是否第一次进入地图;
  435. if (ClickDlgSetup(hWnd, _T("img\\活动\\镜妖\\2-我这就去.bmp")))
  436. {
  437. SRAND(600, 1200);
  438. if (ClickDlgSetup(hWnd, _T("img\\活动\\镜妖\\3-战意镜妖.bmp")))
  439. {
  440. SRAND(600, 1800);
  441. if ((bMatch = ClickDlgSetup(hWnd, _T("img\\活动\\镜妖\\4-我就选择它.bmp"))))
  442. {
  443. SRAND(800, 1800);
  444. }
  445. }
  446. }
  447. }
  448. return;
  449. }
  450. CRect rc;
  451. //POINT spt[4] = { { 175, 280 }, { 225,305 }, { 300, 266 }, { 225,305 } };
  452. POINT spt[4] = { { 260, 360 }, { 300,390}, { 390, 350}, { 280,300 } };
  453. for (int i = 0; !GAssist::GetImgMatchtemplate(hWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\镜妖3.bmp"), rc); i++)
  454. {
  455. // 打开世界地图;
  456. GAssist::SendKey(hWnd, VK_TAB); SRAND(200, 300);
  457. // 选择坐标点;
  458. GAssist::MouseClick(hWnd, spt[i % 4]);
  459. // 退出世界地图;
  460. GAssist::SendKey(hWnd, VK_TAB); SRAND(500, 900);
  461. if (i > 10) {
  462. DebugLog(_T("未找到镜妖+10"));
  463. break;
  464. }
  465. }
  466. // 找到镜妖;
  467. GAssist::MouseMove(hWnd, CPoint(rc.left + rand() % 10, rc.top + rand() % 10));
  468. DebugLog(_T("移动鼠标"));
  469. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 3), TRUE);
  470. SRAND(300, 600);
  471. // 单击目标后,要往移走鼠标,防止下面匹配的时候被鼠标挡住;
  472. GAssist::MouseMove(hWnd, CPoint(rc.right + RAND(5, 12), rc.bottom + RAND(5, 10)));
  473. SRAND(300, 500);
  474. DebugLog(_T("找到目标并单击成功:%s"));
  475. // 我来抓你;
  476. if (GAssist::GetImgMatchtemplate(hWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\我来抓您的.bmp"), rc)) {
  477. // 找到匹配的模块;
  478. GAssist::MouseMove(hWnd, CPoint(rc.left + rand() % 10, rc.top + rand() % 10));
  479. DebugLog(_T("我来抓你:移动鼠标"));
  480. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 3), TRUE);
  481. SRAND(800, 1500);
  482. DebugLog(_T("我来抓你:找到目标并单击成功:%s"));
  483. BOOL bBattle = FALSE;
  484. //while (GAssist::GetImgMatchtemplate(hWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\战斗中.bmp"), rc))
  485. while (IsBattle(hWnd))
  486. {
  487. DebugLog(_T("BattleJY:战斗中"));
  488. //while (GAssist::GetImgMatchtemplate(hWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\技能选择.bmp"), rc))
  489. while (IsWattingAttack(hWnd, 0))
  490. {
  491. DebugLog(_T("BattleJY:我方攻击……"));
  492. if (!bBattle)
  493. {
  494. // 根据角色选择技能;
  495. GAssist::SendKey(hWnd, VK_F1);
  496. SRAND(200, 300);
  497. // 打镜妖喽罗;
  498. GAssist::MouseClick(hWnd, CPoint(290 - 3, 140 - 20));
  499. //GAssist::MouseMove(hWnd, CPoint(220 - 5, 180 - 10));// 打主镜妖;
  500. SRAND(200, 300);
  501. if (bSummoner) {
  502. // 召唤兽技能;
  503. if (GAssist::GetImgMatchtemplate(hWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\召唤兽技能选择.bmp"), rc))
  504. {
  505. SRAND(200, 500);
  506. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 3), TRUE);
  507. DebugLog(_T("BattleJY:召唤兽技能选择"));
  508. // 选择重击;
  509. SRAND(300, 800);
  510. if (GAssist::GetImgMatchtemplate(hWnd, GAssist::g_strAppdir + _T("img\\活动\\镜妖\\重击.bmp"), rc))
  511. {
  512. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 3), TRUE);
  513. }
  514. SRAND(200, 500);
  515. GAssist::MouseMove(hWnd, CPoint(290 - 3, 140 - 15));
  516. GAssist::MouseClick(hWnd, CPoint(290 - 3, 140 - 20));
  517. }
  518. }
  519. else
  520. {
  521. GAssist::SendKey(hWnd, VK_A, FALSE, TRUE);
  522. SRAND(600, 900);
  523. }
  524. bBattle = TRUE;
  525. }
  526. else
  527. {
  528. GAssist::SendKey(hWnd, VK_A, FALSE, TRUE);
  529. SRAND(50, 100);
  530. GAssist::SendKey(hWnd, VK_A, FALSE, TRUE);
  531. SRAND(600, 900);
  532. }
  533. SRAND(300, 550);
  534. }
  535. // 战斗中等待;
  536. SRAND(800, 1200);
  537. }
  538. }
  539. }
  540. // 是否停止走路;
  541. BOOL IsWalkStop(HWND hWnd)
  542. {
  543. // 将鼠标移走,不要在抠图区域;
  544. // 截图,抠指定区域;
  545. // 再截图,抠指定区域与上次抠图结果比较;
  546. // 比较结果相同,表示停止走路;
  547. //POINT pt1 = { 635, 20 };
  548. //POINT pt2 = { 780, 38 };
  549. CRect rc = { 630, 40, 800, 65 };
  550. CRect rc2 = { 640, 45, 770, 63 };
  551. for (int i = 0; i < 100; i++)
  552. {
  553. GAssist::CropPicture(hWnd, rc, _T("walk1.bmp"));
  554. Sleep(600);
  555. GAssist::CropPicture(hWnd, rc2, _T("walk2.bmp"));
  556. // 判断2张图片是否一样;
  557. if (GAssist::IsSimilarPicture(_T("walk1.bmp"), _T("walk2.bmp")))
  558. {
  559. DebugLog(_T("停止走路"));
  560. return TRUE;
  561. }
  562. }
  563. return FALSE;
  564. }
  565. // 世界地图定位;
  566. void WorldMapPositioning(HWND hWnd, POINT ptMap)
  567. {
  568. CRect rc;
  569. //// 打开世界地图;
  570. GAssist::SendKey(hWnd, VK_TAB); SRAND(300, 500);
  571. // 判断是否打开了地图;
  572. if (!GAssist::GetImgMatchtemplate(hWnd, GAssist::g_strAppdir + _T("img\\世界地图.bmp"), rc))
  573. return;
  574. //// 单击寻路窗口;
  575. GAssist::MouseClick(hWnd, ptMap); SRAND(300, 600);
  576. //// 退出世界地址;
  577. GAssist::SendKey(hWnd, VK_TAB); SRAND(200, 300);
  578. IsWalkStop(hWnd);
  579. }
  580. // 使用快捷键来处理:读取配置文件
  581. auto FindJNShortCut = [](LPCTSTR lpSkillName, int& nKeyValue, int& nSkilltime)->BOOL {
  582. // 读取文件:jnmap.bin
  583. // 格式:技能=快捷键的键值;
  584. std::string line;
  585. std::ifstream ifJN("img\\jnmap.bin");
  586. if (ifJN)
  587. {
  588. TCHAR szKeyValue[MAX_PATH] = { 0 };
  589. TCHAR szSkillName[MAX_PATH] = { 0 };
  590. TCHAR szSkillTime[MAX_PATH] = { 0 };
  591. while (std::getline(ifJN, line))
  592. {
  593. int nRet = _stscanf_s(line.c_str(), _T("%[^;];%[^;];%s"), szSkillName, MAX_PATH, szKeyValue, MAX_PATH, szSkillTime, MAX_PATH);
  594. if (nRet == 3 && _tcsicmp(lpSkillName, szSkillName) == 0) {
  595. // 将快捷键值
  596. nKeyValue = atol(szKeyValue);
  597. nSkilltime = atol(szSkillTime);
  598. return TRUE;
  599. }
  600. }
  601. }
  602. // 没有找到jnmap.bin文件;
  603. return FALSE;
  604. };
  605. // 挑战医师;
  606. void BattleYS(HWND hWnd, const char* lpszJN)
  607. {
  608. CRect rc;
  609. BOOL bBattle = FALSE;
  610. if (!FindNPC(hWnd, "医师独侠"))
  611. return;
  612. // 废话少说:表示这个没打过;
  613. rc = FindMatchIcon(hWnd, _T("img\\gdd\\废话少说.bmp"));
  614. if (!rc.IsRectEmpty() && !rc.IsRectNull())
  615. {
  616. // 确定
  617. bBattle = TRUE;
  618. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2), TRUE);
  619. SRAND(230, 350);
  620. GAssist::MouseMoveEx(hWnd, { rc.left, rc.top }, { rc.right + rand() % 10, rc.bottom + rand() % 10 });
  621. SRAND(20, 60);
  622. ClickDlgSetup(hWnd, _T("img\\确定.bmp"));
  623. }
  624. else
  625. {
  626. rc = FindMatchIcon(hWnd, _T("img\\gdd\\离开这里.bmp"));
  627. if (!rc.IsRectEmpty() && !rc.IsRectNull())
  628. {
  629. SRAND(150, 250);
  630. // 只有离开这里:已经打过,右键并退出 ;
  631. DebugLog("只有离开这里:已经打过,右键并退出");
  632. GAssist::MouseRClick(hWnd);
  633. }
  634. else
  635. {
  636. // 找下一页的技能:没有下一页返回-1,找到返回0,没找到返回1;
  637. auto FindNextPageJZ = [&](TCHAR* pJN)->int {
  638. // 没有在当前页找到目标,看看是否在下一页;
  639. rc = FindMatchIcon(hWnd, _T("img\\jn-jk\\gdd\\xyy.bmp"));
  640. if (rc.IsRectEmpty() || rc.IsRectNull())
  641. {
  642. // 没有下一页,右键退出;
  643. GAssist::MouseRClick(hWnd);
  644. return -1;
  645. }
  646. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2), TRUE);
  647. SRAND(300, 350);
  648. // 下一页中查看;
  649. rc = FindMatchIcon(hWnd, pJN);
  650. if (!rc.IsRectEmpty() && !rc.IsRectNull())
  651. {
  652. // 找到目标,单击;
  653. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2), TRUE);
  654. SRAND(300, 500);
  655. // 移动下,防止高亮识别失败;
  656. GAssist::MouseMoveEx(hWnd, { rc.left, rc.top }, { rc.right + rand() % 10, rc.bottom + rand() % 10 });
  657. SRAND(250, 300);
  658. ClickDlgSetup(hWnd, _T("img\\确定.bmp"));
  659. SRAND(250, 300);
  660. rc = FindMatchIcon(hWnd, _T("img\\gdd\\接受挑战.bmp"));
  661. if (!rc.IsRectEmpty() && !rc.IsRectNull())
  662. {// 第二次开始都会多这个;
  663. // 找到目标,单击;
  664. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2), TRUE);
  665. SRAND(300, 500);
  666. // 移动下,防止高亮识别失败;
  667. GAssist::MouseMoveEx(hWnd, { rc.left, rc.top }, { rc.right + rand() % 20, rc.bottom + rand() % 20 });
  668. SRAND(50,150);
  669. }
  670. ClickDlgSetup(hWnd, _T("img\\确定.bmp"));
  671. SRAND(250, 300);
  672. // 战斗;
  673. return 0;
  674. }
  675. return 1;
  676. };
  677. TCHAR szJN[MAX_PATH] = { 0 };
  678. _stprintf_s(szJN, _T("img\\jn-jk\\gdd\\%s.bmp"), lpszJN);
  679. rc = FindMatchIcon(hWnd, szJN);
  680. if (rc.IsRectEmpty() || rc.IsRectNull())
  681. {
  682. // 最多只有三页;
  683. for (int i = 0; i < 3; i++)
  684. {
  685. // 没有在当前页找到目标,看看是否在下一页;
  686. int nRet = FindNextPageJZ(szJN);
  687. if (nRet == 1)
  688. {
  689. // 没有找到技能;
  690. continue;
  691. }
  692. if (nRet == 0)
  693. {
  694. // 找到了;
  695. bBattle = TRUE;
  696. }
  697. break; // 没有下一页也直接break;
  698. }
  699. }
  700. else
  701. {
  702. bBattle = TRUE;
  703. // 找到目标,单击;
  704. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2), TRUE);
  705. SRAND(300, 500);
  706. // 战斗;
  707. ClickDlgSetup(hWnd, _T("img\\确定.bmp"));
  708. SRAND(200, 300);
  709. }
  710. }
  711. }
  712. int KeyValue, SkillTime;
  713. // 进入战斗;
  714. if (bBattle)
  715. {
  716. // 人物:Alt+S显示技能,双击选择技能,单击怪物发动技能;
  717. // 注:有的人物技能太多,导致会有滚动条:这是有难点;
  718. BOOL bRet = FindJNShortCut(lpszJN, KeyValue, SkillTime);
  719. DebugLog("快捷键值=%ld", KeyValue);
  720. // 快捷键;
  721. GAssist::SendKey(hWnd, KeyValue);
  722. SRAND(350, 650);
  723. // 单击指定位置;
  724. GAssist::MouseClick(hWnd, 230, 170);
  725. SRAND(260, 380);
  726. // 将鼠标移动到指定位置;
  727. POINT ptDest = { 625, 28 }; // 左上角;
  728. GAssist::MouseMove(hWnd, ptDest);
  729. while (IsBattle(hWnd))
  730. {
  731. // 判断是否我方攻击;
  732. if (IsWattingAttack(hWnd, 1))
  733. {
  734. GAssist::SendKey(hWnd, VK_A, FALSE, TRUE);
  735. }
  736. SRAND(500, 900);
  737. }
  738. }
  739. // 右键退出;
  740. SRAND(300, 500); //必要的等待时间;
  741. do
  742. {
  743. rc = FindMatchIcon(hWnd, "img\\对话框关闭按钮.bmp");
  744. Sleep(900);
  745. } while (rc.IsRectEmpty() || rc.IsRectNull());
  746. GAssist::MouseRClick(hWnd);
  747. }
  748. void BattleOthers(HWND hWnd, const char* lpszName, const char* lpszSkillName)
  749. {
  750. CRect rc;
  751. BOOL bBattle = FALSE;
  752. if (!_tcsicmp("浪子独侠", lpszName))
  753. {
  754. // 有时会寻路失败;
  755. GAssist::SendKey(hWnd, VK_TAB); SRAND(300, 600);
  756. // 单击指定坐标;
  757. GAssist::MouseClick(hWnd, { 140,430 });
  758. // 关闭地图;
  759. GAssist::SendKey(hWnd, VK_TAB); SRAND(100, 300);
  760. }
  761. if (!FindNPC(hWnd, lpszName))
  762. return;
  763. // 废话少说:表示这个没打过;
  764. rc = FindMatchIcon(hWnd, _T("img\\gdd\\废话少说.bmp"));
  765. if (!rc.IsRectEmpty() && !rc.IsRectNull())
  766. {
  767. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2), TRUE);
  768. SRAND(330, 550);
  769. GAssist::MouseMoveEx(hWnd, { rc.left, rc.top }, { rc.right + rand() % 10, rc.bottom + rand() % 10 });
  770. // 确定
  771. bBattle = TRUE;
  772. ClickDlgSetup(hWnd, _T("img\\确定.bmp"));
  773. SRAND(250, 350);
  774. }
  775. else
  776. {
  777. rc = FindMatchIcon(hWnd, _T("img\\gdd\\离开这里.bmp"));
  778. }
  779. int KeyValue, SkillTime;
  780. if (bBattle) {
  781. BOOL bRet = FindJNShortCut(lpszSkillName, KeyValue, SkillTime);
  782. // 将鼠标移动到指定位置;
  783. POINT ptDest = { 625, 28 }; // 左上角;
  784. GAssist::MouseMove(hWnd, ptDest);
  785. while (IsBattle(hWnd))
  786. {
  787. // 判断是否我方攻击;
  788. if (IsWattingAttack(hWnd, 1))
  789. {
  790. GAssist::SendKey(hWnd, VK_A, FALSE, TRUE);
  791. }
  792. SRAND(500, 750);
  793. }
  794. }
  795. // 右键退出;
  796. if (_tcsicmp(lpszName, _T("魂武独侠")))
  797. {
  798. SRAND(300, 500);
  799. do
  800. {
  801. rc = FindMatchIcon(hWnd, "img\\对话框关闭按钮.bmp");
  802. Sleep(900);
  803. } while (rc.IsRectEmpty() || rc.IsRectNull());
  804. GAssist::MouseRClick(hWnd);
  805. }
  806. else
  807. {
  808. // 回到应天府;
  809. GAssist::MouseMoveEx(hWnd, { rc.left, rc.top }, { rc.right + rand() % 10, rc.bottom + rand() % 10 });
  810. ClickDlgSetup(hWnd, _T("\\img\\gdd\\送我回应天府.bmp"));
  811. }
  812. }
  813. // 用于应用程序“关于”菜单项的 CAboutDlg 对话框
  814. class CAboutDlg : public CDialog
  815. {
  816. public:
  817. CAboutDlg();
  818. // 对话框数据
  819. enum { IDD = IDD_ABOUTBOX };
  820. protected:
  821. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
  822. // 实现
  823. protected:
  824. DECLARE_MESSAGE_MAP()
  825. };
  826. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  827. {
  828. }
  829. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  830. {
  831. CDialog::DoDataExchange(pDX);
  832. }
  833. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  834. END_MESSAGE_MAP()
  835. // CGameAssistDlg 对话框
  836. CGameAssistDlg::CGameAssistDlg(CWnd* pParent /*=NULL*/)
  837. : CDialog(CGameAssistDlg::IDD, pParent)
  838. {
  839. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  840. }
  841. void CGameAssistDlg::DoDataExchange(CDataExchange* pDX)
  842. {
  843. CDialog::DoDataExchange(pDX);
  844. DDX_Control(pDX, IDC_CHECK1, m_cbSummoner);
  845. DDX_Control(pDX, IDC_CHECK2, m_cbZJ);
  846. DDX_Control(pDX, IDC_CHECK3, m_cbZJ2);
  847. DDX_Control(pDX, IDC_CHECK6, m_cbAggressiveSkill);
  848. DDX_Control(pDX, IDC_COMBO1, m_cbGameRole);
  849. }
  850. BEGIN_MESSAGE_MAP(CGameAssistDlg, CDialog)
  851. ON_WM_SYSCOMMAND()
  852. ON_WM_PAINT()
  853. ON_WM_QUERYDRAGICON()
  854. //}}AFX_MSG_MAP
  855. ON_BN_CLICKED(BTN_OPENGAME, &CGameAssistDlg::OnBnClickedOpengame)
  856. ON_BN_CLICKED(IDC_BUTTON2, &CGameAssistDlg::OnBnClickedButton2)
  857. ON_BN_CLICKED(IDC_BUTTON3, &CGameAssistDlg::OnBnClickedButton3)
  858. ON_BN_CLICKED(IDC_BUTTON4, &CGameAssistDlg::OnBnClickedButton4)
  859. ON_BN_CLICKED(IDC_BUTTON5, &CGameAssistDlg::OnBnClickedButton5)
  860. ON_BN_CLICKED(IDC_BUTTON6, &CGameAssistDlg::OnBnClickedButton6)
  861. ON_BN_CLICKED(IDC_BUTTON7, &CGameAssistDlg::OnBnClickedButton7)
  862. ON_BN_CLICKED(IDC_BUTTON8, &CGameAssistDlg::OnBnClickedButton8)
  863. ON_BN_CLICKED(IDC_BUTTON9, &CGameAssistDlg::OnBnClickedButton9)
  864. ON_BN_CLICKED(IDC_BUTTON10, &CGameAssistDlg::OnBnClickedButton10)
  865. ON_BN_CLICKED(IDC_BUTTON11, &CGameAssistDlg::OnBnClickedButton11)
  866. ON_BN_CLICKED(IDC_BUTTON12, &CGameAssistDlg::OnBnClickedButton12)
  867. END_MESSAGE_MAP()
  868. // CGameAssistDlg 消息处理程序
  869. BOOL CGameAssistDlg::OnInitDialog()
  870. {
  871. CDialog::OnInitDialog();
  872. // 将“关于...”菜单项添加到系统菜单中。
  873. // IDM_ABOUTBOX 必须在系统命令范围内。
  874. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  875. ASSERT(IDM_ABOUTBOX < 0xF000);
  876. CMenu* pSysMenu = GetSystemMenu(FALSE);
  877. if (pSysMenu != NULL)
  878. {
  879. BOOL bNameValid;
  880. CString strAboutMenu;
  881. bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
  882. ASSERT(bNameValid);
  883. if (!strAboutMenu.IsEmpty())
  884. {
  885. pSysMenu->AppendMenu(MF_SEPARATOR);
  886. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  887. }
  888. }
  889. // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
  890. // 执行此操作
  891. SetIcon(m_hIcon, TRUE); // 设置大图标
  892. SetIcon(m_hIcon, FALSE); // 设置小图标
  893. // TODO: 在此添加额外的初始化代码
  894. GAssist::Init();
  895. return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
  896. }
  897. void CGameAssistDlg::OnSysCommand(UINT nID, LPARAM lParam)
  898. {
  899. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  900. {
  901. CAboutDlg dlgAbout;
  902. dlgAbout.DoModal();
  903. }
  904. else
  905. {
  906. CDialog::OnSysCommand(nID, lParam);
  907. }
  908. }
  909. // 如果向对话框添加最小化按钮,则需要下面的代码
  910. // 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序,
  911. // 这将由框架自动完成。
  912. void CGameAssistDlg::OnPaint()
  913. {
  914. if (IsIconic())
  915. {
  916. CPaintDC dc(this); // 用于绘制的设备上下文
  917. SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
  918. // 使图标在工作区矩形中居中
  919. int cxIcon = GetSystemMetrics(SM_CXICON);
  920. int cyIcon = GetSystemMetrics(SM_CYICON);
  921. CRect rect;
  922. GetClientRect(&rect);
  923. int x = (rect.Width() - cxIcon + 1) / 2;
  924. int y = (rect.Height() - cyIcon + 1) / 2;
  925. // 绘制图标
  926. dc.DrawIcon(x, y, m_hIcon);
  927. }
  928. else
  929. {
  930. CDialog::OnPaint();
  931. }
  932. }
  933. //当用户拖动最小化窗口时系统调用此函数取得光标
  934. //显示。
  935. HCURSOR CGameAssistDlg::OnQueryDragIcon()
  936. {
  937. return static_cast<HCURSOR>(m_hIcon);
  938. }
  939. void CGameAssistDlg::OnBnClickedOpengame()
  940. {
  941. #if 1 // 获取游戏标题;
  942. DWORD dwPid = GAssist::GetProcessId();
  943. HWND hProWnd = GAssist::GetProMainHwnd(dwPid);
  944. //HWND hProWnd = GAssist::GetProMainHwnd(5824);
  945. TCHAR szWinText[MAX_PATH] = { 0 };
  946. ::GetWindowText(hProWnd, szWinText, MAX_PATH);
  947. #if 1
  948. Sleep(1000);
  949. m_mouseAssist.BindWnd(hProWnd, PT_TYPE::WINDOW_POINT);
  950. m_mouseAssist.MoveTo(205, 150);
  951. Sleep(1000);
  952. m_mouseAssist.MoveTo(250, 250);
  953. Sleep(1000);
  954. m_mouseAssist.MoveTo(350, 350);
  955. Sleep(1000);
  956. m_mouseAssist.MoveTo(10, 470);
  957. m_mouseAssist.LeftClick();
  958. /*GAssist::MouseMove(hProWnd, CPoint(205,150));
  959. Sleep(2000);
  960. GAssist::MouseMove(hProWnd, CPoint(100,100), CPoint(250,250));
  961. Sleep(2000);
  962. GAssist::MouseMove(hProWnd, CPoint(100,100), CPoint(350,350));*/
  963. return;
  964. #endif
  965. if (0)
  966. {
  967. Sleep(1000);
  968. GAssist::MouseClick(hProWnd, CPoint(205, 150));
  969. Sleep(1000);
  970. GAssist::MouseClick(hProWnd, CPoint(235, 150));
  971. Sleep(1000);
  972. GAssist::MouseClick(hProWnd, CPoint(275, 150));
  973. }
  974. if (0)
  975. {
  976. Sleep(1000);
  977. ::SetForegroundWindow(hProWnd);
  978. GAssist::DragMouse(hProWnd, CPoint(173, 192), CPoint(295, 190));
  979. }
  980. if (0) {
  981. GAssist::MouseDbClick(hProWnd, CPoint(476, 158));
  982. }
  983. if (0)
  984. {
  985. GAssist::SendKey(hProWnd, VK_TAB);
  986. }
  987. //RECT rc = {0,0,500,500};
  988. //HBITMAP hb = GAssist::CopyDC2Bitmap(hProWnd, &rc);
  989. //GAssist::SaveBitmap(hb, "1.bmp");
  990. //GAssist::SaveHwndToBmpFile(hProWnd, "2.bmp");
  991. return;
  992. #endif
  993. // TODO: 在此添加控件通知处理程序代码
  994. if (!PathFileExists(GAssist::g_szGameApp))
  995. {
  996. MessageBox("游戏程序不存在", "温馨提示");
  997. return;
  998. }
  999. // 设置辅助程序工作目录为游戏目录;
  1000. //SetCurrentDirectory(_T("E:\\dhsh\\shdata\\"));
  1001. SetCurrentDirectory(_T("D:\\tools\\dhsh\\shdata\\"));
  1002. #if 1
  1003. ShellExecute(NULL, "open", GAssist::g_szGameApp, NULL, NULL, SW_SHOWNORMAL);//SW_HIDE无用,因为会自动结;
  1004. Sleep(500); // Main.exe设置了陷阱(自己再开启了一个进程,结束上一个进程),需要等5秒;
  1005. #else
  1006. SHELLEXECUTEINFO stuExecInfo = { 0 };
  1007. DWORD dwExitCode = STILL_ACTIVE;
  1008. //CString strCommandLine = _T("open");
  1009. stuExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
  1010. stuExecInfo.lpFile = GAssist::g_szGamePath;
  1011. stuExecInfo.lpParameters = "open";
  1012. stuExecInfo.nShow = SW_SHOWNORMAL;
  1013. stuExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
  1014. if (!ShellExecuteEx(&stuExecInfo))
  1015. {
  1016. DWORD dwError = GetLastError();
  1017. CString strError = _T("");
  1018. strError.Format(_T("执行ShellExecuteEx失败,错误码:%d"), dwError);
  1019. AfxMessageBox(strError);
  1020. return;
  1021. }
  1022. HANDLE hProcess = stuExecInfo.hProcess;
  1023. if (hProcess != NULL)
  1024. {
  1025. WaitForSingleObject(hProcess, INFINITE);
  1026. CloseHandle(hProcess);
  1027. }
  1028. #endif
  1029. DWORD dwPID = GAssist::FindProcess(_T("Main.exe"));
  1030. #if 1
  1031. EnumWindows(GAssist::EnumChildWindowCallBack, dwPID);
  1032. if (GAssist::g_vtGameHwnd.size())
  1033. {
  1034. GAssist::GameHwnd* gp = NULL;
  1035. GAssist::GameHwnd* gbmin = NULL;
  1036. GAssist::GameHwnd* gbentry = NULL;
  1037. for (std::vector<GAssist::GameHwnd>::iterator it = GAssist::g_vtGameHwnd.begin(); it != GAssist::g_vtGameHwnd.end(); it++)
  1038. {
  1039. if (_tcsicmp(it->strWinText.c_str(), _T("最小化")) == 0)
  1040. {
  1041. gbmin = &*it;
  1042. }
  1043. if (_tcsicmp(it->strWinText.c_str(), _T("大话水浒")) == 0)
  1044. {
  1045. gp = &*it;
  1046. }
  1047. if (_tcsicmp(it->strWinText.c_str(), _T("进入游戏")) == 0)
  1048. {
  1049. gbentry = &*it;
  1050. }
  1051. }
  1052. if (gp && gbentry && gbmin)
  1053. {
  1054. //::SendMessage(gp->hwnd, WM_LBUTTONDOWN, (WPARAM)gb->dwId, 0);
  1055. //::SendMessage(gp->hwnd, WM_LBUTTONUP, (WPARAM)gb->dwId, 0);
  1056. // 发送点击事件;
  1057. // 先最小化;
  1058. ::SendMessage(gp->hwnd, WM_COMMAND, gbmin->dwId, NULL);
  1059. // 再进入;
  1060. ::SendMessage(gp->hwnd, WM_COMMAND, gbentry->dwId, NULL);
  1061. Sleep(1500);
  1062. dwPID = GAssist::GetProcessId();
  1063. if (dwPID)
  1064. {
  1065. GAssist::g_vtGameHwnd.clear();
  1066. EnumWindows(GAssist::EnumChildWindowCallBack, dwPID);
  1067. HWND hwnd = GAssist::GetProMainHwnd(dwPID);
  1068. if (hwnd)
  1069. {
  1070. TCHAR szName[MAX_PATH] = { 0 };
  1071. ::GetWindowText(hwnd, szName, MAX_PATH);
  1072. CRect rc;
  1073. ::GetWindowRect(hwnd, &rc);
  1074. TCHAR szLogMsg[MAX_PATH] = { 0 };
  1075. _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());
  1076. OutputDebugString(szLogMsg);
  1077. if (1)
  1078. { // 800x600
  1079. // 发送按钮消息;进入游戏;
  1080. GAssist::MouseClick(hwnd, 585, 116);
  1081. // 发送按钮消息;下一步;
  1082. GAssist::MouseClick(hwnd, 536, 481);
  1083. // 发送按钮消息;电信一区;
  1084. GAssist::MouseClick(hwnd, 229, 342);
  1085. // 发送按钮消息;忘忧谷;
  1086. GAssist::MouseClick(hwnd, 335, 244);
  1087. // 发送按钮消息;下一步;
  1088. GAssist::MouseClick(hwnd, 559, 516);
  1089. }
  1090. else
  1091. {
  1092. // 640x480
  1093. // 发送按钮消息;进入游戏;
  1094. GAssist::MouseClick(hwnd, 440, 75);
  1095. // 发送按钮消息;下一步;
  1096. GAssist::MouseClick(hwnd, 468, 454);
  1097. // 发送按钮消息;电信一区;
  1098. GAssist::MouseClick(hwnd, 165, 241);
  1099. // 发送按钮消息;忘忧谷;
  1100. GAssist::MouseClick(hwnd, 289, 195);
  1101. // 发送按钮消息;下一步;
  1102. GAssist::MouseClick(hwnd, 494, 469);
  1103. }
  1104. }
  1105. }
  1106. }
  1107. }
  1108. #endif
  1109. }
  1110. void CGameAssistDlg::OnBnClickedButton2() // 截图;
  1111. {
  1112. // TODO: 在此添加控件通知处理程序代码
  1113. HWND hWnd = GAssist::GetProcessMainWnd();
  1114. UpdateData();
  1115. INT nX = GetDlgItemInt(IDC_EDIT3);
  1116. INT nY = GetDlgItemInt(IDC_EDIT4);
  1117. INT nX2 = GetDlgItemInt(IDC_EDIT5);
  1118. INT nY2 = GetDlgItemInt(IDC_EDIT6);
  1119. BOOL bCropPicture = ((CButton*)GetDlgItem(IDC_CHECK5))->GetCheck();
  1120. if (bCropPicture)
  1121. {
  1122. GAssist::CropPicture(hWnd, { nX, nY, nX2, nY2 }, _T("裁剪结果.bmp"));
  1123. }
  1124. else
  1125. {
  1126. CString strImg;
  1127. strImg = CTime::GetCurrentTime().Format("%H%M%S-Game.bmp");
  1128. GAssist::SaveHwndToBmpFile(hWnd, strImg.GetString());
  1129. }
  1130. #if 0
  1131. HWND hWnd = GAssist::GetProcessMainWnd();
  1132. #if 1
  1133. // 快捷键;
  1134. //GAssist::SendKey(hProWnd, VK_F3);
  1135. //SRAND(350, 650);
  1136. //// 单击指定位置;
  1137. //GAssist::MouseClick(hProWnd, 230, 170);
  1138. //SRAND(260, 380);
  1139. //// 将鼠标移动到指定位置;
  1140. //POINT ptDest = { 625, 28 }; // 左上角;
  1141. //GAssist::MouseMove(hProWnd, ptDest);
  1142. // 有时会寻路失败;
  1143. GAssist::SendKey(hWnd, VK_TAB); SRAND(300, 600);
  1144. // 单击指定坐标;
  1145. //GAssist::MouseClick(hWnd, { 80,500 });
  1146. GAssist::MouseMove(hWnd, { 80, 580 });
  1147. // 关闭地图;
  1148. GAssist::SendKey(hWnd, VK_TAB); SRAND(100, 300);
  1149. #else
  1150. //IsWattingAttack(hProWnd, 1);
  1151. //BattleYS(hProWnd, "缚神诀");
  1152. char szName[10][32] = { "术士独侠","道士独侠","武师独侠","浪子独侠",
  1153. "剑客独侠","弓手独侠","禁卫独侠","墨者独侠","巫煞独侠","魂武独侠" };
  1154. BattleOthers(hProWnd, szName[9], _T("缚神诀"));
  1155. #endif
  1156. // auto FindJNShortCut = [](LPCTSTR lpSkillName)->int {
  1157. // // 读取文件:jnmap.bin
  1158. // // 格式:技能=快捷键的键值;
  1159. // std::string line;
  1160. // std::ifstream ifJN("..\\img\\jnmap.bin");
  1161. // if (ifJN)
  1162. // {
  1163. // TCHAR szKeyValue[MAX_PATH] = { 0 };
  1164. // TCHAR szSkillName[MAX_PATH] = { 0 };
  1165. // while (std::getline(ifJN, line))
  1166. // {
  1167. // int nRet = _stscanf_s(line.c_str(), _T("%[^=]%s"), szSkillName, MAX_PATH, szKeyValue, MAX_PATH);
  1168. // if (nRet == 2 && _tcsicmp(lpSkillName, szSkillName) == 0) {
  1169. // // 将快捷键值
  1170. // return atol(szKeyValue);
  1171. // }
  1172. // }
  1173. //}
  1174. //
  1175. // // 没有找到jnmap.bin文件;
  1176. // return -1;
  1177. // };
  1178. //
  1179. //int KeyValue, SkillTime;
  1180. //FindJNShortCut("缚神诀", KeyValue, SkillTime);
  1181. #endif
  1182. #if 0
  1183. CRect rc;
  1184. HWND hProWnd = GAssist::GetProcessMainWnd();
  1185. // POINT spt= { 20, 555 }; // 左下角;
  1186. //POINT spt = { 20, 50 }; // 左上角
  1187. POINT spt = { 625, 28 }; // 战斗时的右上角
  1188. // 选择坐标点;
  1189. GAssist::MouseMove(hProWnd, spt);
  1190. CString strImg;
  1191. //strImg = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S %W-%A");
  1192. strImg = CTime::GetCurrentTime().Format("%H%M%S-Game.bmp");
  1193. GAssist::SaveHwndToBmpFile(hProWnd, strImg.GetString());
  1194. #endif
  1195. #if 0
  1196. CRect rc;
  1197. HWND hProWnd = GAssist::GetProcessMainWnd();
  1198. POINT spt[4] = { { 250, 335 }, { 310,360}, { 385, 315}, { 280,295 } };
  1199. static int i = 2;
  1200. if (i < 4)
  1201. {
  1202. // 打开世界地图;
  1203. GAssist::SendKey(hProWnd, VK_TAB); SRAND(200, 300);
  1204. // 选择坐标点;
  1205. GAssist::MouseClick(hProWnd, spt[i % 4]);
  1206. // 退出世界地图;
  1207. GAssist::SendKey(hProWnd, VK_TAB); SRAND(500, 900);
  1208. DebugLog(_T("%d = [x,y] = (%d, %d)"), i, spt[i].x, spt[i].y);
  1209. i++;
  1210. }
  1211. else
  1212. {
  1213. i = 0;
  1214. }
  1215. #endif
  1216. // GAssist::MouseMove(hProWnd, CPoint(290 - 5, 140 - 20));
  1217. //
  1218. // Sleep(5000);
  1219. // GAssist::MouseMove(hProWnd, CPoint(220 - 5, 180 - 10));
  1220. }
  1221. void CGameAssistDlg::OnBnClickedButton3() // 镜妖;
  1222. {
  1223. UpdateData();
  1224. /*
  1225. -- 是否在星秀村
  1226. -- 是否在贫民房
  1227. |-- 否:我帮您抓
  1228. |-- -- 是否进入过贫民房
  1229. | |-- 否:我这就去
  1230. | | |-- 选择:幸运镜妖
  1231. | | |-- 我就选择它
  1232. | |-- 是:直接进入贫民房
  1233. |-- 是:找到镜妖NPC
  1234. | |-- 我来抓您的
  1235. | |
  1236. | |
  1237. |
  1238. |
  1239. */
  1240. CRect rc;
  1241. HWND hProWnd = GAssist::GetProcessMainWnd();
  1242. int nZJType = 0;
  1243. if (m_cbZJ.GetCheck() || m_cbZJ2.GetCheck())
  1244. {
  1245. if (m_cbZJ.GetCheck())
  1246. nZJType = 1;
  1247. if (m_cbZJ2.GetCheck())
  1248. nZJType = 2;
  1249. }
  1250. for (int i = 0; i < 100; i++)
  1251. {
  1252. UpdateData(FALSE);
  1253. DebugLog(_T("start.打镜妖 %d----------------------------"), i);
  1254. BattleJY(hProWnd, m_cbSummoner.GetCheck(), nZJType, m_cbAggressiveSkill.GetCheck());
  1255. DebugLog(_T("end.打镜妖 %d----------------------------\n"), i);
  1256. }
  1257. }
  1258. void CGameAssistDlg::OnBnClickedButton4() // 周六领礼物
  1259. {
  1260. // TODO: 在此添加控件通知处理程序代码
  1261. // 星秀村:送礼协会会长丙
  1262. // 【星】铜钱怪
  1263. HWND hWnd = GAssist::GetProcessMainWnd();
  1264. FindNPC(hWnd, _T("送礼协会会长丙"));
  1265. IsWalkStop(hWnd);
  1266. if (ClickDlgSetup(hWnd, _T("img\\活动\\周六礼物\\我来领取礼物.bmp")))
  1267. {
  1268. if (ClickDlgSetup(hWnd, _T("img\\活动\\周六礼物\\好的.bmp")))
  1269. {
  1270. FindNPC(hWnd, _T("【星】铜钱怪"));
  1271. IsWalkStop(hWnd);
  1272. CRect rc;
  1273. //铜钱怪:好的,要问些什么问题呢?
  1274. struct MyStruct
  1275. {
  1276. BOOL bDone = FALSE;
  1277. TCHAR szQuestion[MAX_PATH] = { 0 };
  1278. };
  1279. if (ClickDlgSetup(hWnd, _T("img\\活动\\周六礼物\\铜钱怪:好的,要问些什么问题呢?.bmp")))
  1280. {
  1281. // 第一次回答;
  1282. std::vector<MyStruct> vtMyst1 = { {FALSE, _T("img\\活动\\周六礼物\\铜钱怪:帮派就象个大家庭.bmp")},
  1283. {FALSE, _T("img\\活动\\周六礼物\\铜钱怪:交流的场所.bmp")},
  1284. {FALSE, _T("img\\活动\\周六礼物\\铜钱怪:能够认识很多.bmp")},
  1285. {FALSE, _T("img\\活动\\周六礼物\\铜钱怪:我希望能够.bmp")},
  1286. {FALSE, _T("img\\活动\\周六礼物\\铜钱怪:由系统定时发布.bmp")},
  1287. {FALSE, _T("img\\活动\\周六礼物\\铜钱怪:好的,快点问吧.bmp")}
  1288. };
  1289. for (; vtMyst1.size();)
  1290. {
  1291. for (std::vector<MyStruct>::iterator it = vtMyst1.begin(); it != vtMyst1.end(); it++)
  1292. {
  1293. rc = FindMatchIcon(hWnd, it->szQuestion);
  1294. if (!rc.IsRectEmpty() && !rc.IsRectNull())
  1295. {
  1296. // 单击目标回答;
  1297. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 5));
  1298. // 再移动下鼠标,防止高亮影响下次的判断;
  1299. GAssist::MouseMove(hWnd, CPoint(rc.right + RAND(6, 20), rc.bottom + RAND(6, 20)));
  1300. // 等待下一个问题出现;
  1301. SRAND(200, 300);
  1302. it = vtMyst1.erase(it);
  1303. break;
  1304. }
  1305. }
  1306. }
  1307. // 第二次回答;
  1308. std::vector<MyStruct> vtMyst2 = { {FALSE, _T("img\\活动\\周六礼物\\铜钱怪:帮派就象个大家庭.bmp")},
  1309. {FALSE, _T("img\\活动\\周六礼物\\铜钱怪:交流的场所.bmp")},
  1310. {FALSE, _T("img\\活动\\周六礼物\\铜钱怪:能够认识很多.bmp")},
  1311. {FALSE, _T("img\\活动\\周六礼物\\铜钱怪:我希望能够.bmp")},
  1312. {FALSE, _T("img\\活动\\周六礼物\\铜钱怪:由系统定时发布.bmp")}
  1313. };
  1314. for (; vtMyst2.size();)
  1315. {
  1316. for (std::vector<MyStruct>::iterator it = vtMyst2.begin(); it != vtMyst2.end(); it++)
  1317. {
  1318. rc = FindMatchIcon(hWnd, it->szQuestion);
  1319. if (!rc.IsRectEmpty() && !rc.IsRectNull())
  1320. {
  1321. // 单击目标回答;
  1322. GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 5));
  1323. // 再移动下鼠标,防止高亮影响下次的判断;
  1324. GAssist::MouseMove(hWnd, CPoint(rc.right + RAND(6, 20), rc.bottom + RAND(6, 20)));
  1325. // 等待下一个问题出现;
  1326. SRAND(200, 300);
  1327. it = vtMyst2.erase(it);
  1328. break;
  1329. }
  1330. }
  1331. }
  1332. // 回答完所有问题,右键退出;
  1333. SRAND(200, 300);
  1334. GAssist::MouseRClick(hWnd);
  1335. }
  1336. // 再次回到送礼协会会长;
  1337. FindNPC(hWnd, _T("送礼协会会长丙"));
  1338. IsWalkStop(hWnd);
  1339. // 再右键一次;
  1340. SRAND(200, 300);
  1341. GAssist::MouseRClick(hWnd);
  1342. FindNPC(hWnd, _T("送礼协会会长丙"));
  1343. if (ClickDlgSetup(hWnd, _T("img\\活动\\周六礼物\\好,现在就去.bmp")))
  1344. {
  1345. // 等待切换地图;
  1346. SRAND(800, 900);
  1347. }
  1348. }
  1349. }
  1350. if (IsOnMap(hWnd, _T("img\\地图\\汴京城.bmp")))
  1351. {
  1352. // 找送礼协会会长丁
  1353. FindNPC(hWnd, _T("送礼协会会长丁"));
  1354. IsWalkStop(hWnd);
  1355. SRAND(300, 500); // 等对话框出现;
  1356. if (ClickDlgSetup(hWnd, _T("img\\活动\\周六礼物\\我来领取礼物.bmp")))
  1357. {
  1358. if (ClickDlgSetup(hWnd, _T("img\\活动\\周六礼物\\好的.bmp")))
  1359. {
  1360. // 找铜钱怪;
  1361. FindNPC(hWnd, _T("【汴】铜钱怪"));
  1362. IsWalkStop(hWnd);
  1363. SRAND(300, 500);
  1364. if (ClickDlgSetup(hWnd, _T("img\\活动\\周六礼物\\铜钱怪:进入战斗.bmp")))
  1365. {
  1366. // 将鼠标移动到指定位置;
  1367. POINT ptDest = { 625, 28 }; // 左上角;
  1368. GAssist::MouseMove(hWnd, ptDest);
  1369. while (IsBattle(hWnd))
  1370. {
  1371. // 判断是否我方攻击;
  1372. if (IsWattingAttack(hWnd, 1))
  1373. {
  1374. GAssist::SendKey(hWnd, VK_A, FALSE, TRUE);
  1375. }
  1376. SRAND(500, 750);
  1377. }
  1378. // 送礼协会会长乙;
  1379. FindNPC(hWnd, _T("送礼协会会长乙"));
  1380. IsWalkStop(hWnd);
  1381. // 再右键一次;
  1382. SRAND(200, 300);
  1383. GAssist::MouseRClick(hWnd);
  1384. FindNPC(hWnd, _T("送礼协会会长丙")); SRAND(200, 300);
  1385. if (ClickDlgSetup(hWnd, _T("img\\活动\\周六礼物\\好,现在就去.bmp")))
  1386. {
  1387. // 等待切换地图;
  1388. SRAND(800, 900);
  1389. }
  1390. }
  1391. }
  1392. }
  1393. }
  1394. if (IsOnMap(hWnd, _T("img\\地图\\应天府.bmp")))
  1395. {
  1396. // 找送礼协会会长丁
  1397. FindNPC(hWnd, _T("送礼协会会长甲"));
  1398. IsWalkStop(hWnd);
  1399. SRAND(300, 500); // 等对话框出现;
  1400. if (ClickDlgSetup(hWnd, _T("img\\活动\\周六礼物\\我来领取礼物.bmp")))
  1401. {
  1402. if (ClickDlgSetup(hWnd, _T("img\\活动\\周六礼物\\好的.bmp")))
  1403. {
  1404. // 找铜钱怪;
  1405. FindNPC(hWnd, _T("【应】铜钱怪"));
  1406. IsWalkStop(hWnd);
  1407. SRAND(300, 500);
  1408. if (ClickDlgSetup(hWnd, _T("img\\活动\\周六礼物\\铜钱怪:进入战斗.bmp")))
  1409. {
  1410. // 将鼠标移动到指定位置;
  1411. POINT ptDest = { 625, 28 }; // 左上角;
  1412. GAssist::MouseMove(hWnd, ptDest);
  1413. while (IsBattle(hWnd))
  1414. {
  1415. // 判断是否我方攻击;
  1416. if (IsWattingAttack(hWnd, 1))
  1417. {
  1418. GAssist::SendKey(hWnd, VK_A, FALSE, TRUE);
  1419. }
  1420. SRAND(500, 750);
  1421. }
  1422. // 送礼协会会长乙;
  1423. FindNPC(hWnd, _T("送礼协会会长甲"));
  1424. IsWalkStop(hWnd);
  1425. SRAND(1000, 2000);
  1426. GAssist::MouseRClick(hWnd);
  1427. }
  1428. }
  1429. }
  1430. }
  1431. }
  1432. void CGameAssistDlg::OnBnClickedButton5() // 开宝箱;
  1433. {
  1434. HWND hProcessMainWnd = GAssist::GetProcessMainWnd();
  1435. if (GAssist::nGameWndType == GAssist::GW_SMALL)
  1436. {
  1437. CRect rc;
  1438. MouseAssist mouseAssist;
  1439. mouseAssist.BindWnd(hProcessMainWnd, PT_TYPE::SCREEN_POINT);
  1440. for (int i = 0; i < 50; i++)
  1441. {
  1442. if (!GAssist::GetImgMatchtemplate(hProcessMainWnd, GAssist::g_strAppdir + _T("img\\开宝箱\\应天府铁匠.bmp"), rc))
  1443. {
  1444. // 没找到,要将鼠标从目标中移走;并且要右击一次将目标的高亮状态取消;
  1445. mouseAssist.SetCursorPos(rc.top + rand() % 5, rc.left + rand() % 5);
  1446. mouseAssist.MoveTo(rc.top - rand() % 5, rc.left - rand() % 5);
  1447. mouseAssist.RightClick();
  1448. }
  1449. else
  1450. {
  1451. GAssist::MouseClick(hProcessMainWnd, CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 5));
  1452. Sleep(600 + rand() % 30);
  1453. // 再移动下,会更高精度;
  1454. mouseAssist.MoveTo(rc.top - rand() % 15, rc.left - rand() % 15);
  1455. // 判断是否还有对话,如果没有的话表明不是第一次进入;
  1456. if (GAssist::GetImgMatchtemplate(hProcessMainWnd, GAssist::g_strAppdir + _T("img\\开宝箱\\开宝箱.bmp"), rc)) {
  1457. GAssist::MouseClick(hProcessMainWnd, CPoint((rc.right + rc.left) / 2 + rand() % 2, (rc.top + rc.bottom) / 2 + rand() % 2));
  1458. Sleep(rand() % 200 + 190);
  1459. // 然后移动出去;
  1460. //GAssist::MouseMove(hProcessMainWnd, CPoint(rc.top - 50 - rand()%20, rc.left - 50 - rand() % 20));
  1461. mouseAssist.SetCursorPos(rc.top + rand() % 5, rc.left + rand() % 5);
  1462. mouseAssist.MoveToEx(rc.top, rc.left, rc.Width(), rc.Height());
  1463. }
  1464. }
  1465. Sleep(600 + rand() % 300);
  1466. }
  1467. }
  1468. }
  1469. void CGameAssistDlg::OnBnClickedButton6() // 职业挑战;
  1470. {
  1471. CRect rc;
  1472. DebugLog(_T("进入孤独洞========="));
  1473. HWND hProWnd = GAssist::GetProcessMainWnd();
  1474. if (!FindNPC(hProWnd, "职业训导大师"))
  1475. return;
  1476. // 选择进入;
  1477. BOOL bMatch = FALSE;
  1478. int trySize = 20;
  1479. // 我要挑战他们;
  1480. while (!(bMatch = ClickDlgSetup(hProWnd, _T("img\\zyxdds-wytztm.bmp")))) {
  1481. SRAND(1200, 2200);
  1482. if (!trySize--) break;
  1483. }
  1484. // 准备好了
  1485. if (ClickDlgSetup(hProWnd, _T("img\\zyxdds-zbhl.bmp")))
  1486. {
  1487. // 地图切换,等出图;
  1488. SRAND(2000, 2500);
  1489. if (IsOnMap(hProWnd, _T("img\\gdd\\name.bmp")))
  1490. {
  1491. DebugLog(_T("进入孤独洞"));
  1492. char szName[10][32] = { "术士独侠","道士独侠","武师独侠","浪子独侠","剑客独侠","弓手独侠","禁卫独侠","墨者独侠","巫煞独侠","魂武独侠" };
  1493. BattleYS(hProWnd, "缚神诀");
  1494. for (int i = 0; i < 10; i++)
  1495. {
  1496. BattleOthers(hProWnd, szName[i], "缚神诀");
  1497. }
  1498. }
  1499. }
  1500. }
  1501. void CGameAssistDlg::OnBnClickedButton7() // 家园任务;
  1502. {
  1503. // TODO: 在此添加控件通知处理程序代码
  1504. }
  1505. void CGameAssistDlg::OnBnClickedButton8() // 职业挑战2;
  1506. {
  1507. // TODO: 在此添加控件通知处理程序代码
  1508. CRect rc;
  1509. DebugLog(_T("进入孤独洞========="));
  1510. HWND hProWnd = GAssist::GetProcessMainWnd();
  1511. DebugLog(_T("进入孤独洞"));
  1512. char szName[10][32] = { "术士独侠","道士独侠","武师独侠","浪子独侠","剑客独侠","弓手独侠","禁卫独侠","墨者独侠","巫煞独侠","魂武独侠" };
  1513. for (int i = 0; i < 10; i++)
  1514. {
  1515. BattleOthers(hProWnd, szName[i], "缚神诀");
  1516. }
  1517. }
  1518. void CGameAssistDlg::OnBnClickedButton9() // 移动到目标点
  1519. {
  1520. // TODO: 在此添加控件通知处理程序代码
  1521. HWND hWnd = GAssist::GetProcessMainWnd();
  1522. UpdateData();
  1523. INT nX = GetDlgItemInt(IDC_EDIT1);
  1524. INT nY = GetDlgItemInt(IDC_EDIT2);
  1525. BOOL bOpenMap = ((CButton*)GetDlgItem(IDC_CHECK4))->GetCheck();
  1526. if (bOpenMap)
  1527. WorldMapPositioning(hWnd, { nX, nY });
  1528. else
  1529. GAssist::MouseMove(hWnd, { nX, nY });
  1530. }
  1531. void CGameAssistDlg::OnBnClickedButton10()
  1532. {
  1533. // TODO: 在此添加控件通知处理程序代码
  1534. CRect rc;
  1535. HWND hProWnd = GAssist::GetProcessMainWnd();
  1536. int nZJType = 0;
  1537. if (m_cbZJ.GetCheck() || m_cbZJ2.GetCheck())
  1538. {
  1539. if (m_cbZJ.GetCheck())
  1540. nZJType = 1;
  1541. if (m_cbZJ2.GetCheck())
  1542. nZJType = 2;
  1543. }
  1544. UpdateData(FALSE);
  1545. DebugLog(_T("start.打镜妖 %d----------------------------"));
  1546. BattleJY(hProWnd, m_cbSummoner.GetCheck(), nZJType, m_cbAggressiveSkill.GetCheck());
  1547. DebugLog(_T("end.打镜妖 %d----------------------------\n"));
  1548. }
  1549. void CGameAssistDlg::OnBnClickedButton11()
  1550. {
  1551. // TODO: 在此添加控件通知处理程序代码
  1552. }
  1553. void CGameAssistDlg::OnBnClickedButton12()
  1554. {
  1555. // TODO: 在此添加控件通知处理程序代码
  1556. HWND hWnd = GAssist::GetProcessMainWnd();
  1557. while ( true )
  1558. {
  1559. while (IsBattle(hWnd))
  1560. {
  1561. if ( IsWattingAttack(hWnd,1) )
  1562. {
  1563. GAssist::SendKey(hWnd, VK_A, FALSE, TRUE);
  1564. }
  1565. Sleep(900);
  1566. }
  1567. Sleep(600);
  1568. }
  1569. }