Wang Jeff преди 4 години
родител
ревизия
f5caae46c6
променени са 1 файла, в които са добавени 20 реда и са изтрити 17 реда
  1. 20 17
      GameAssist/GameAssist/GameAssistDlg.cpp

+ 20 - 17
GameAssist/GameAssist/GameAssistDlg.cpp

@@ -6,6 +6,7 @@
 #include "GameAssist.h"
 #include "GameAssistDlg.h"
 //#include "VideoDXGICaptor.h"
+#include "MouseAssist.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -169,7 +170,7 @@ HCURSOR CGameAssistDlg::OnQueryDragIcon()
 void CGameAssistDlg::OnBnClickedOpengame()
 {
 #if 1 // 获取游戏标题;
-	DWORD dwPid = GAssist::FindProcess(_T("Game.exe"));
+	DWORD dwPid = GAssist::GetProcessId();
 	HWND hProWnd = GAssist::GetProMainHwnd(dwPid);
 	//HWND hProWnd = GAssist::GetProMainHwnd(5824);
 	TCHAR szWinText[MAX_PATH] = {0};
@@ -379,7 +380,7 @@ void CGameAssistDlg::OnBnClickedOpengame()
 
 
 			Sleep(1500);
-			dwPID = GAssist::FindProcess(_T("Game.exe"));
+			dwPID = GAssist::GetProcessId();
 			if ( dwPID )
 			{
 				GAssist::g_vtGameHwnd.clear();
@@ -441,7 +442,7 @@ void CGameAssistDlg::OnBnClickedButton2()
 // 		vdx.CaptureImage(pData, len);
 // 		vdx.Deinit();
 // 	}
-	DWORD dwPid = GAssist::FindProcess(_T("Game.exe"));
+	DWORD dwPid = GAssist::GetProcessId();
 	HWND hProWnd = GAssist::GetProMainHwnd(dwPid);
 	// 截图;
 	GAssist::SaveHwndToBmpFile(hProWnd, "Game.bmp");
@@ -451,7 +452,7 @@ void CGameAssistDlg::OnBnClickedButton2()
 void CGameAssistDlg::OnBnClickedButton3()
 {
 	// 获取进程句柄;
-	DWORD dwPid = GAssist::FindProcess(_T("Game.exe"));
+	DWORD dwPid = GAssist::GetProcessId();
 	HWND hProWnd = GAssist::GetProMainHwnd(dwPid);
 
 	
@@ -580,25 +581,27 @@ void CGameAssistDlg::OnBnClickedButton4()
 
 void CGameAssistDlg::OnBnClickedButton5()
 {
-	// TODO: 在此添加控件通知处理程序代码
-	// 获取进程句柄;
-	DWORD dwPid = GAssist::FindProcess(_T("Game.exe"));
-	HWND hProWnd = GAssist::GetProMainHwnd(dwPid);
-
-
+	HWND hProcessMainWnd = GAssist::GetProcessMainWnd();
 	if (GAssist::nGameWndType == GAssist::GW_SMALL)
 	{
-		// 对话;
 		CRect rc;
-		for (int i = 0; i < 200; i++)
+		MouseAssist mouseAssist;
+		mouseAssist.BindWnd(hProcessMainWnd, PT_TYPE::SCREEN_POINT);
+		for (int i = 0; i < 2; i++)
 		{
-			if (GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\开宝箱\\应天府铁匠.bmp"), rc)) {
-				GAssist::MouseClick(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
-				Sleep(100);
+			if (!GAssist::GetImgMatchtemplate(hProcessMainWnd, GAssist::g_strAppdir + _T("img\\开宝箱\\应天府铁匠.bmp"), rc))
+			{
+				// 在当前位置右键一次;
+				GAssist::MouseDbClick(hProcessMainWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
+			}
+			else
+			{
+				GAssist::MouseClick(hProcessMainWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
+				Sleep(500);
 				// 判断是否还有对话,如果没有的话表明不是第一次进入;
-				if (GAssist::GetImgMatchtemplate(hProWnd, GAssist::g_strAppdir + _T("img\\开宝箱\\开宝箱.bmp"), rc)) {
+				if (GAssist::GetImgMatchtemplate(hProcessMainWnd, GAssist::g_strAppdir + _T("img\\开宝箱\\开宝箱.bmp"), rc)) {
 
-					GAssist::MouseDbClick(hProWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
+					GAssist::MouseDbClick(hProcessMainWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
 					Sleep(200);
 				}
 			}