GameAssistDlg.cpp 45 KB

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