sat23 4 жил өмнө
parent
commit
189f3a8f22

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 1 - 1239
GameAssist/GameAssist/Assist.cpp


+ 11 - 121
GameAssist/GameAssist/Assist.h

@@ -6,126 +6,6 @@
 #include <map>
 #include <string>
 
-namespace GAssist
-{
-	enum {
-		GW_SMALL,
-		GW_LARGE,
-		GW_FULL,
-	}GAME_WND;
-	extern int titleBarHeight;
-	extern int frameWidth;
-
-	extern TCHAR g_szCurModuleFileName[MAX_PATH];
-	extern TCHAR g_szCurModuleDir[MAX_PATH];
-	extern TCHAR g_szCurModulePath[MAX_PATH];
-	extern TCHAR g_szFna[_MAX_FNAME];
-	extern TCHAR g_szExt[_MAX_EXT];
-	extern TCHAR g_szAssistConfig[MAX_PATH];
-	extern std::string g_strAppdir;
-	extern std::string g_strGameDir;
-	extern TCHAR g_szGameApp[MAX_PATH];
-	extern int nGameWndType;
-
-
-	typedef struct __GAME_HWNINFO__ {
-		DWORD			dwId;				// 控件id;
-		std::string		strWinText;			// 控件文本;
-		std::string		strClassName;		// 控件类名;
-		HWND			hwnd;				// 控件句柄;
-	}GameHwnd, * pGameHwnd;
-
-	// key_event的virtaul+scan
-	extern std::map<byte, byte> vsKey;
-
-	extern std::vector<GameHwnd> g_vtGameHwnd;
-
-	typedef struct __GAMEWNDINFO__
-	{
-		unsigned long       lProcId;				// 进程ID;
-		HWND                hWnd;					// 进程窗口句柄;
-		std::string			strGameRoleName;		// 角色名称;
-		std::string			strGameZoon;			// 区域;
-		std::string			strGameServer;			// 服务站
-	}GameWndInfo, * pGameWndInfo;
-	extern std::vector<GameWndInfo> g_vtGameWndInfo;
-
-	typedef struct __GAC__ {
-		bool				bLogin;                 // 登录状态;
-		std::string			strAccount;             // 账号;
-		std::string			strPassword;            // 密码;
-		unsigned long		lRoleNumber;            // 角色ID;
-		std::string			strRoleName;            // 角色名称;
-		std::string			strRoleType;            // 角色类型:剑客、武师、医师、道士、术士;
-		unsigned short		nRoleLevel;             // 角色等级;
-		std::string			strRoleZone;            // 角色所在区:电信一区……;
-		std::string			strRoleSuit;            // 角色所在服:忘忧谷;
-		// 关联某进程信息;
-		unsigned long       lProcId;				// 进程ID;
-		HWND                hWnd;					// 进程窗口句柄;
-		unsigned char       wndType;				// 窗口类型:0=小窗口、1=大窗口、2=全屏;
-		std::string			strWndText;				// 窗口名称;
-		__GAC__() {
-			bLogin = false;
-			lProcId = 0;
-			lRoleNumber = 0;
-			nRoleLevel = 0;
-			wndType = 0;
-		}
-	}GUserInfo, * PGUserInfo;
-	extern std::vector<GUserInfo> g_vtGUserInfo;
-
-	extern void Init();
-	extern void GetGameConfig();
-	extern void ShowLog(const TCHAR* format, ...);
-	extern BOOL CALLBACK EnumChildWindowCallBack(HWND hWnd, LPARAM lParam);
-
-	// 根据进程名获取进程pid;
-	extern DWORD GetProcessId(LPCTSTR lpProcessName = _T("Game.exe"));
-	extern void GetAllProcessId(std::vector<DWORD> &vtPid, LPCTSTR lpProcessName = _T("Game.exe"));
-	// 根据进程pid获取进程对应程序的窗口句柄;
-	extern HWND GetProcessMainWnd(const DWORD &dwTagetProcessId, LPCTSTR lpTagetWndName = _T("大话水浒"));
-	extern void GetAllProcessMainWnd(const std::vector<DWORD> &vtPid, std::vector<GameWndInfo> &vtGWnd, LPCTSTR lpTagetWndName = _T("大话水浒"));
-	extern HWND GetProcessMainWnd(LPCTSTR lpProcessName = _T("Game.exe"), LPCTSTR lpTagetWndName = _T("大话水浒"));
-	// 启动游戏;
-	extern void StartGame(std::string strGameDir, int nStartCount = 5);
-	// 单击事件;
-	extern void MouseClick(HWND hwnd, POINT pt, BOOL bClientRect = TRUE);
-	extern void MouseClick(HWND hwnd, unsigned int x, unsigned int y);
-	extern void MouseDbClick(HWND, POINT pt);
-	extern void MouseRClick(HWND hwnd, POINT pt, BOOL bClientRect = TRUE);
-	extern void MouseRClick(HWND hwnd, unsigned int x, unsigned int y);
-	extern void MouseRClick(HWND hwnd);
-	// 移动鼠标;
-	extern void MouseMove(HWND hwnd, POINT pt);
-	extern void MouseMove(HWND hwnd, POINT ptStart, POINT ptEnd);
-	extern void MouseMoveEx(HWND hwnd, POINT ptStart, POINT ptEnd);
-	// 拖动鼠标;
-	extern void DragMouse(HWND hwnd, POINT ptStart, POINT ptEnd);
-	extern void SendKey(HWND hwnd, DWORD key, BOOL bCtrl = FALSE, BOOL bAtl = FALSE, BOOL bShift = FALSE);
-	BOOL SetClipboardString(const char* lpString);
-	CString GetClipboradString();
-	// 截图;
-	HBITMAP CopyDC2Bitmap(HWND hWnd, LPRECT lpRect);
-	// 保存图片;
-	BOOL SaveBitmap(HBITMAP hBitmpa, std::string strSavePath);
-	//void SaveHwndToBmpFile(HWND hWnd, LPCTSTR lpszPath);
-	void SaveHwndToBmpFile(HWND hWnd, std::string strSavePath);
-	bool IsCoveredByOtherWindow(HWND  hWnd);
-
-	BOOL OpenImage(std::string strImag, cv::Mat &img);
-	BOOL SetImgThreshold(cv::Mat &srcImg, cv::Mat &thresholdImg, long nThresholdVal, long nMaxThresholdVal, int type = 0);
-	BOOL GetImgMatchtemplate(HWND hWnd, std::string strTempImg, RECT& rc, double lowestMatchValue = 0.900);
-	BOOL GetImgMatchtemplate(std::string strSrcImg, std::string strTempImg, RECT &rc, double lowestMatchValue = 0.900);
-	BOOL IsMatchIcon(HWND hWnd, std::string strTempImg, RECT srcRect, RECT& matchRect, double lowestMatchValue = 0.900);
-	BOOL CropPicture(HWND hWnd, CRect rc, const char* szSaveName); // 剪裁图片;
-	BOOL IsSimilarPicture(const char* szp1, const char* szp2, double lowestMatchValue = 0.99);
-	
-	// 职业大挑战;
-	void ZhiYeDaTiaoZhan();
-	BOOL IsWin10DpiScaleEanbled();
-};
-
 namespace GameGlobal {
 	enum {
 		GW_SMALL,
@@ -166,6 +46,15 @@ namespace ImgAssist {
 // 所有坐标,都是基于游戏窗口的相对坐标值;
 // 游戏窗口:802*627
 namespace GameAssist{
+	// 控件信息;
+	typedef struct __CTRL_INFO__ {
+		DWORD			dwId;				// 控件id;
+		std::string		strWinText;			// 控件文本;
+		std::string		strClassName;		// 控件类名;
+		HWND			hwnd;				// 控件句柄;
+	}CtrlInfo, * pCtrlInfo;
+	extern std::vector<CtrlInfo> g_vtCtrlInfo;
+
 	typedef struct __GAMEWNDINFO__
 	{
 		unsigned long       lProcId;				// 进程ID;
@@ -218,7 +107,8 @@ namespace GameAssist{
 	HWND GetProcessMainWnd(LPCTSTR lpProcessName = _T("Game.exe"), LPCTSTR lpTagetWndName = _T("大话水浒"));
 	// 获取所有指定进程名的进程主窗口;
 	void GetAllProcessMainWnd(const std::vector<DWORD>& vtPid, std::vector<GameWndInfo>& vtGWnd, LPCTSTR lpTagetWndName = _T("大话水浒"));
-	
+	// 枚举指定进程的窗口;
+	extern BOOL CALLBACK EnumChildWindowCallBack(HWND hWnd, LPARAM lParam);
 };
 
 #endif // __ASSIST__

+ 5 - 5
GameAssist/GameAssist/CAction.cpp

@@ -285,13 +285,13 @@ SRAND(80,120);
 		//// 湖羲岍賜華芞;
 		SendKey(VK_TAB); SRAND(550, 800);
 		// 瓚剿岆瘁湖羲賸華芞;
-		if (!ImgAssist::GetImgMatchtemplate(m_hGameWnd, GAssist::g_strAppdir + _T("img\\岍賜華芞.bmp"), rc))
+		if (!ImgAssist::GetImgMatchtemplate(m_hGameWnd, GameGlobal::g_strAppdir + _T("img\\岍賜華芞.bmp"), rc))
 			return;
 
 		//// 等僻扆繚敦諳;
 		MouseClick(ptMap); SRAND(300, 600);
 		
-		while (ImgAssist::GetImgMatchtemplate(m_hGameWnd, GAssist::g_strAppdir + _T("img\\岍賜華芞.bmp"), rc)) {
+		while (ImgAssist::GetImgMatchtemplate(m_hGameWnd, GameGlobal::g_strAppdir + _T("img\\岍賜華芞.bmp"), rc)) {
 			// 豖堤岍賜華硊;
 			SendKey(VK_TAB); SRAND(200, 300);
 		}
@@ -352,7 +352,7 @@ SRAND(80,120);
 		MouseMove(CPoint((rc.right + rc.left) / 2 + 5 + rand() % 2, (rc.top + rc.bottom) / 2 + 60 + rand() % 2)); SRAND(200, 300);
 		//// 扆繚敦諳厘狟50憩岆醴梓;
 		MouseDbClick(CPoint((rc.right + rc.left) / 2 + 5 + rand() % 2, (rc.top + rc.bottom) / 2 + 60 + rand() % 2)); SRAND(200, 300);
-		while (ImgAssist::GetImgMatchtemplate(m_hGameWnd, GAssist::g_strAppdir + _T("img\\岍賜華芞.bmp"), rc)) {
+		while (ImgAssist::GetImgMatchtemplate(m_hGameWnd, GameGlobal::g_strAppdir + _T("img\\岍賜華芞.bmp"), rc)) {
 			// 豖堤岍賜華硊;
 			SendKey(VK_TAB); SRAND(200, 300);
 		}
@@ -582,7 +582,7 @@ SRAND(80,120);
 				SendKey(VK_TAB); SRAND(200, 300);
 				// 恁寁釴梓萸;
 				MouseClick(spt[i % 4]);
-				while (ImgAssist::GetImgMatchtemplate(m_hGameWnd, GAssist::g_strAppdir + _T("img\\岍賜華芞.bmp"), rc)) {
+				while (ImgAssist::GetImgMatchtemplate(m_hGameWnd, GameGlobal::g_strAppdir + _T("img\\岍賜華芞.bmp"), rc)) {
 					// 豖堤岍賜華硊;
 					SendKey(VK_TAB); SRAND(500, 900);
 				}
@@ -862,7 +862,7 @@ SRAND(80,120);
 					MouseClick(CPoint((rc.right + rc.left) / 2 + rand() % 2, (rc.top + rc.bottom) / 2 + rand() % 2));
 					Sleep(rand() % 200 + 190);
 					// �綴痄雄堤�;
-					//GAssist::MouseMove(hProcessMainWnd, CPoint(rc.top - 50 - rand()%20, rc.left - 50 - rand() % 20));
+					//GameGlobal::MouseMove(hProcessMainWnd, CPoint(rc.top - 50 - rand()%20, rc.left - 50 - rand() % 20));
 					MouseMoveEx({ rc.top + RAND(0, rc.Height()), rc.left + RAND(0, rc.Width()) });
 				}
 			}

+ 4 - 0
GameAssist/GameAssist/CAction.h

@@ -92,6 +92,10 @@ public:
 		bool FindNPCByIconAndPos(LPCTSTR lpszNPCName, POINT ptMap, POINT ptNpc);
 		// 查找NPC:查找map中的NPC;
 		bool FindNPCByMap(LPCTSTR lpszNPCName);
+		// 是否低于SP安全值
+		bool IsSPBelowSafeValue();
+		// 是否低于HP安全值
+		bool IsHPBelowSafeValue();
 
 	public:
 		// 与镜妖战斗;

+ 0 - 4
GameAssist/GameAssist/GameAssist.cpp

@@ -322,10 +322,6 @@ BOOL CGameAssistApp::InitInstance()
 	HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void**)&pCreateDevEnum);
 #endif
 
-	GAssist::IsWin10DpiScaleEanbled();
-
-
-
 	// 标准初始化
 	// 如果未使用这些功能并希望减小
 	// 最终可执行文件的大小,则应移除下列

+ 28 - 32
GameAssist/GameAssist/GameAssistDlg.cpp

@@ -220,9 +220,9 @@ GameAssist::GameWndInfo* CGameAssistDlg::GetCurGameInfo()
 void CGameAssistDlg::OnBnClickedOpengame() // 打开游戏;
 {
 	// TODO: 在此添加控件通知处理程序代码
-	if (!PathFileExists(GAssist::g_szGameApp))
+	if (!PathFileExists(GameGlobal::g_szGameApp))
 	{
-		MessageBox("游戏程序不存在", "温馨提示");
+		MessageBox(_T("游戏程序不存在", "温馨提示"));
 		return;
 	}
 
@@ -230,14 +230,14 @@ void CGameAssistDlg::OnBnClickedOpengame() // 
 	//SetCurrentDirectory(_T("E:\\dhsh\\shdata\\"));
 	SetCurrentDirectory(_T("D:\\tools\\dhsh\\shdata\\"));
 #if 1
-	ShellExecute(NULL, "open", GAssist::g_szGameApp, NULL, NULL, SW_SHOWNORMAL);//SW_HIDE无用,因为会自动结;
+	ShellExecute(NULL, "open", GameGlobal::g_szGameApp, NULL, NULL, SW_SHOWNORMAL);//SW_HIDE无用,因为会自动结;
 	Sleep(500); // Main.exe设置了陷阱(自己再开启了一个进程,结束上一个进程),需要等5秒;
 #else
 	SHELLEXECUTEINFO stuExecInfo = { 0 };
 	DWORD dwExitCode = STILL_ACTIVE;
 	//CString strCommandLine = _T("open");
 	stuExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
-	stuExecInfo.lpFile = GAssist::g_szGamePath;
+	stuExecInfo.lpFile = GameGlobal::g_szGamePath;
 	stuExecInfo.lpParameters = "open";
 	stuExecInfo.nShow = SW_SHOWNORMAL;
 	stuExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
@@ -260,16 +260,16 @@ void CGameAssistDlg::OnBnClickedOpengame() // 
 
 #endif
 
-	DWORD dwPID = GAssist::GetProcessId(_T("Main.exe"));
+	DWORD dwPID = GameAssist::GetProcessId(_T("Main.exe"));
 #if 1
-	EnumWindows(GAssist::EnumChildWindowCallBack, dwPID);
+	EnumWindows(GameAssist::EnumChildWindowCallBack, dwPID);
 
-	if (GAssist::g_vtGameHwnd.size())
+	if (GameAssist::g_vtCtrlInfo.size())
 	{
-		GAssist::GameHwnd* gp = NULL;
-		GAssist::GameHwnd* gbmin = NULL;
-		GAssist::GameHwnd* gbentry = NULL;
-		for (std::vector<GAssist::GameHwnd>::iterator it = GAssist::g_vtGameHwnd.begin(); it != GAssist::g_vtGameHwnd.end(); it++)
+		GameAssist::CtrlInfo* gp = NULL;
+		GameAssist::CtrlInfo* gbmin = NULL;
+		GameAssist::CtrlInfo* gbentry = NULL;
+		for (std::vector<GameAssist::CtrlInfo>::iterator it = GameAssist::g_vtCtrlInfo.begin(); it != GameAssist::g_vtCtrlInfo.end(); it++)
 		{
 			if (_tcsicmp(it->strWinText.c_str(), _T("最小化")) == 0)
 			{
@@ -299,12 +299,12 @@ void CGameAssistDlg::OnBnClickedOpengame() // 
 
 
 			Sleep(1500);
-			dwPID = GAssist::GetProcessId();
+			dwPID = GameAssist::GetProcessId();
 			if (dwPID)
 			{
-				GAssist::g_vtGameHwnd.clear();
-				EnumWindows(GAssist::EnumChildWindowCallBack, dwPID);
-				HWND hwnd = GAssist::GetProcessMainWnd(dwPID);
+				GameAssist::g_vtCtrlInfo.clear();
+				EnumWindows(GameAssist::EnumChildWindowCallBack, dwPID);
+				HWND hwnd = GameAssist::GetProcessMainWnd(dwPID);
 				if (hwnd)
 				{
 					TCHAR szName[MAX_PATH] = { 0 };
@@ -317,29 +317,29 @@ void CGameAssistDlg::OnBnClickedOpengame() // 
 					if (1)
 					{ // 800x600
 						// 发送按钮消息;进入游戏;
-						GAssist::MouseClick(hwnd, 585, 116);
+						GameAssist::MouseClick({585, 116});
 						// 发送按钮消息;下一步;
-						GAssist::MouseClick(hwnd, 536, 481);
+						GameAssist::MouseClick({536, 481});
 						// 发送按钮消息;电信一区;
-						GAssist::MouseClick(hwnd, 229, 342);
+						GameAssist::MouseClick({229, 342});
 						// 发送按钮消息;忘忧谷;
-						GAssist::MouseClick(hwnd, 335, 244);
+						GameAssist::MouseClick({335, 244});
 						// 发送按钮消息;下一步;
-						GAssist::MouseClick(hwnd, 559, 516);
+						GameAssist::MouseClick({559, 516});
 					}
 					else
 					{
 						// 640x480
 						// 发送按钮消息;进入游戏;
-						GAssist::MouseClick(hwnd, 440, 75);
+						GameAssist::MouseClick({440, 75});
 						// 发送按钮消息;下一步;
-						GAssist::MouseClick(hwnd, 468, 454);
+						GameAssist::MouseClick({468, 454});
 						// 发送按钮消息;电信一区;
-						GAssist::MouseClick(hwnd, 165, 241);
+						GameAssist::MouseClick({165, 241});
 						// 发送按钮消息;忘忧谷;
-						GAssist::MouseClick(hwnd, 289, 195);
+						GameAssist::MouseClick({289, 195});
 						// 发送按钮消息;下一步;
-						GAssist::MouseClick(hwnd, 494, 469);
+						GameAssist::MouseClick({494, 469});
 					}
 				}
 			}
@@ -553,23 +553,19 @@ void CGameAssistDlg::OnBnClickedButton12()
 	GameAssist::GameWndInfo* pGameInfo = GetCurGameInfo();
 	if (pGameInfo && pGameInfo->pAction)
 	{
-		// 将鼠标移动到指定位置;
-		POINT ptDest = { 625, 28 }; // 左上角;
 		GameAssist::CAction* pAction = (GameAssist::CAction*)pGameInfo->pAction;
-
 		while (GameGlobal::nAttackCount--)
 		{
 			BOOL bFirst = TRUE;
 			while (pAction->IsBattle())
 			{
-				pAction->MouseMove(ptDest);
 				if (pAction->IsWattingAttack(-1))
 				{
-					if (0)
+					if (bFirst)
 					{
 						pAction->SendKey(VK_F1);
-						Sleep(30);
-						pAction->MouseClick({ 226, 158 });
+						//Sleep(30);
+						//pAction->MouseClick({ 226, 158 });
 						bFirst = FALSE;
 					}
 					else

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно