Przeglądaj źródła

修复BattleOthers函数。

Wang Jeff 4 lat temu
rodzic
commit
df18148d46

+ 43 - 29
GameAssist/GameAssist/GameAssistDlg.cpp

@@ -91,12 +91,12 @@ CRect FindMatchIcon(HWND hWnd, LPCSTR lpszTemplateImage)
 	::ShowWindow(hWnd, SW_SHOWNORMAL);
 	::SetForegroundWindow(hWnd);
 	// 先截图;
-	DebugLog(_T("IsOnMap=%s"), lpszTemplateImage);
+	DebugLog(_T("FindMatchIcon=%s"), lpszTemplateImage);
 	GAssist::SaveHwndToBmpFile(hWnd, GAssist::g_strAppdir + _T("Game.bmp")); SRAND(200, 500);
 	_stprintf_s(szTemplateImage, _T("%s%s"), GAssist::g_strAppdir.c_str(), lpszTemplateImage);
 	if (GAssist::GetImgMatchtemplate(GAssist::g_strAppdir + _T("Game.bmp"), szTemplateImage, rc)) {
 		// 找到匹配的模块;
-		DebugLog(_T("找到匹配目标:%s"), lpszTemplateImage);
+		DebugLog(_T("==>找到匹配目标:%s"), lpszTemplateImage);
 		return rc;
 	}
 
@@ -682,9 +682,19 @@ void BattleYS(HWND hWnd, const char* lpszJN)
 					GAssist::MouseMoveEx(hWnd, {rc.left, rc.top}, {rc.right+rand()%10, rc.bottom + rand()%10});
 					SRAND(150, 200);
 					ClickDlgSetup(hWnd, _T("img\\确定.bmp"));
-					SRAND(150, 200);
+					//SRAND(150, 200);
+					
+					rc = FindMatchIcon(hWnd, _T("img\\gdd\\接受挑战.bmp"));
+					if ( !rc.IsRectEmpty() && !rc.IsRectNull() )
+					{// 第二次开始都会多这个;
+						// 找到目标,单击;
+						GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2), TRUE);
+						SRAND(300, 500);
+					}
+
 					ClickDlgSetup(hWnd, _T("img\\确定.bmp"));
 					SRAND(150, 200);
+
 					// 战斗;
 					return 0;
 				}
@@ -795,12 +805,15 @@ void BattleOthers(HWND hWnd, const char* lpszName)
 	{
 		rc = FindMatchIcon(hWnd, "img\\对话框关闭按钮.bmp");
 		Sleep(900);
-	} while (!rc.IsRectEmpty() && !rc.IsRectNull());
+	} while (rc.IsRectEmpty() || rc.IsRectNull());
 
 	// 废话少说:表示这个没打过;
 	rc = FindMatchIcon(hWnd, _T("img\\gdd\\废话少说.bmp"));
 	if (!rc.IsRectEmpty() && !rc.IsRectNull())
 	{
+		GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2), TRUE);
+		SRAND(330, 550);
+		GAssist::MouseMoveEx(hWnd, { rc.left, rc.top }, { rc.right + rand() % 10, rc.bottom + rand() % 10 });
 		// 确定
 		bBattle = TRUE;
 		ClickDlgSetup(hWnd, _T("img\\确定.bmp"));
@@ -1198,31 +1211,32 @@ void CGameAssistDlg::OnBnClickedButton2()  // 
 #if 1
 	HWND hProWnd = GAssist::GetProcessMainWnd();
 	//IsWattingAttack(hProWnd, 1);
-	BattleYS(hProWnd, "缚神诀");
-	auto FindJNShortCut = [](LPCTSTR lpSkillName)->int {
-		// 读取文件:jnmap.bin
-		// 格式:技能=快捷键的键值;
-		std::string line;
-		std::ifstream ifJN("..\\img\\jnmap.bin");
-		if (ifJN)
-		{
-			TCHAR szKeyValue[MAX_PATH] = { 0 };
-			TCHAR szSkillName[MAX_PATH] = { 0 };
-			while (std::getline(ifJN, line))
-			{
-				int nRet = _stscanf_s(line.c_str(), _T("%[^=]%s"), szSkillName, MAX_PATH, szKeyValue, MAX_PATH);
-				if (nRet == 2 && _tcsicmp(lpSkillName, szSkillName) == 0) {
-					// 将快捷键值
-					return atol(szKeyValue);
-				}
-	}
-}
-
-		// 没有找到jnmap.bin文件;
-		return -1;
-		};
-
-	int KeyValue = FindJNShortCut("缚神诀");
+	//BattleYS(hProWnd, "缚神诀");
+	BattleOthers(hProWnd, "术士独侠");
+//	auto FindJNShortCut = [](LPCTSTR lpSkillName)->int {
+//		// 读取文件:jnmap.bin
+//		// 格式:技能=快捷键的键值;
+//		std::string line;
+//		std::ifstream ifJN("..\\img\\jnmap.bin");
+//		if (ifJN)
+//		{
+//			TCHAR szKeyValue[MAX_PATH] = { 0 };
+//			TCHAR szSkillName[MAX_PATH] = { 0 };
+//			while (std::getline(ifJN, line))
+//			{
+//				int nRet = _stscanf_s(line.c_str(), _T("%[^=]%s"), szSkillName, MAX_PATH, szKeyValue, MAX_PATH);
+//				if (nRet == 2 && _tcsicmp(lpSkillName, szSkillName) == 0) {
+//					// 将快捷键值
+//					return atol(szKeyValue);
+//				}
+//	}
+//}
+//
+//		// 没有找到jnmap.bin文件;
+//		return -1;
+//		};
+//
+//	int KeyValue = FindJNShortCut("缚神诀");
 #endif
 
 #if 0

BIN
GameAssist/img/gdd/接受挑战.bmp