Browse Source

添加新函数。

Jeff Wang 1 year ago
parent
commit
837e272838

+ 24 - 0
GameAssist/GameAssist/Assist.cpp

@@ -300,6 +300,30 @@ namespace GameAssist
 			keybd_event(VK_SHIFT, 0x2A, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
 	}
 
+	void SendKeyFast(DWORD key, BOOL bCtrl, BOOL bAtl, BOOL bShift)
+	{
+		if (bCtrl)
+			keybd_event(VK_CONTROL, 0x1D, KEYEVENTF_EXTENDEDKEY | 0, 0);
+		if (bAtl)
+			keybd_event(VK_MENU, 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
+		if (bShift)
+			keybd_event(VK_SHIFT, 0x2A, KEYEVENTF_EXTENDEDKEY | 0, 0);
+
+		Sleep(80);	// 注意:有些电脑能响应Ctrl+V,有些不行,则需要加大CTRL与V之间的时间间隔;
+		// key down;
+		keybd_event(key, 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
+		// key up;
+		keybd_event(key, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
+
+		Sleep(80);
+		if (bCtrl)
+			keybd_event(VK_CONTROL, 0x1D, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
+		if (bAtl)
+			keybd_event(VK_MENU, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
+		if (bShift)
+			keybd_event(VK_SHIFT, 0x2A, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
+	}
+
 	CString GetClipboradString()
 	{
 		if (OpenClipboard(NULL))

+ 1 - 1
GameAssist/GameAssist/Assist.h

@@ -91,7 +91,7 @@ namespace GameAssist{
 
 	// 发送按键;
 	void SendKey(DWORD key, BOOL bCtrl = FALSE, BOOL bAtl = FALSE, BOOL bShift = FALSE);
-
+	void SendKeyFast(DWORD key, BOOL bCtrl = FALSE, BOOL bAtl = FALSE, BOOL bShift = FALSE);
 	// 获取剪切板字符串;
 	CString GetClipboradString();
 	// 设置剪切板字符串;

+ 15 - 5
GameAssist/GameAssist/CAction.cpp

@@ -10,6 +10,12 @@ if (!::IsWindow(m_hGameWnd)) return;\
 ::SetForegroundWindow(m_hGameWnd);\
 SRAND(80,120);
 
+#define SETGAMEFOREGROUND2 AutoThreadSection ats(&m_ts);\
+if (!::IsWindow(m_hGameWnd)) return;\
+::ShowWindow(m_hGameWnd, SW_SHOWNORMAL);\
+::SetForegroundWindow(m_hGameWnd);\
+SRAND(30,50);
+
 	std::map<std::string, POINT> g_mapZYNPC;
 	std::map<std::string, PNPC> g_mapZYNPC2;
 	std::map<std::string, METAGRAPH> g_mapMetaGraph;
@@ -154,6 +160,12 @@ SRAND(80,120);
 		SRAND(80, 150);
 	}
 
+	void CAction::SendKeyFast(DWORD key, BOOL bCtrl, BOOL bAtl, BOOL bShift)
+	{
+		SETGAMEFOREGROUND2;
+		GameAssist::SendKeyFast(key, bCtrl, bAtl, bShift);
+	}
+
 	void CAction::InitNPCInfo()
 	{
 		static bool bInit = false;
@@ -1317,19 +1329,17 @@ SRAND(80,120);
 			{
 				if (pAction->IsWattingAttack(-1))
 				{
-					SRAND(50, 150);
-					pAction->SendKey(VK_A, FALSE, TRUE);
+					pAction->SendKeyFast(VK_A, FALSE, TRUE);
 				}
-				Sleep(50);
 			}
 
-			if (pAction->IsSPBelowSafeValue(TRUE, TRUE, 10))
+			if (pAction->IsSPBelowSafeValue(TRUE, TRUE, 50))
 			{
 				// ÓÒ¼ü;
 				pAction->MouseMove({ (GameAssist::g_rcRoleIdleSP.right + GameAssist::g_rcRoleIdleSP.left) / 2, (GameAssist::g_rcRoleIdleSP.bottom + GameAssist::g_rcRoleIdleSP.top) / 2 });
 				pAction->MouseRClick({ (GameAssist::g_rcRoleIdleSP.right + GameAssist::g_rcRoleIdleSP.left) / 2, (GameAssist::g_rcRoleIdleSP.bottom + GameAssist::g_rcRoleIdleSP.top) / 2 });
 			}
-		} while (WaitForSingleObject(pAction->m_hBattleJYEvent, 100) == WAIT_TIMEOUT);
+		} while (WaitForSingleObject(pAction->m_hBattleJYEvent, 50) == WAIT_TIMEOUT);
 
 		return 0;
 	}

+ 1 - 1
GameAssist/GameAssist/CAction.h

@@ -84,7 +84,7 @@ public:
 
 		// ·¢ËÍ°´¼ü;
 		void SendKey(DWORD key, BOOL bCtrl = FALSE, BOOL bAtl = FALSE, BOOL bShift = FALSE);
-
+		void SendKeyFast(DWORD key, BOOL bCtrl = FALSE, BOOL bAtl = FALSE, BOOL bShift = FALSE);
 	public:
 		CAction(HWND hWnd);
 		~CAction();