GameAssistDlg.cpp 53 KB

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