From ef5268ada9219c6aa7ac87b5ee4dbd3715c2d52a Mon Sep 17 00:00:00 2001 From: "xu.kai" Date: Mon, 22 Apr 2024 00:11:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BC=A0=E6=A0=87=E7=82=B9=E5=87=BB=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E8=B0=83=E7=94=A8=E7=8E=B0=E6=9C=89=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libop/background/mouse/opMouseDx.cpp | 23 ++++-------- libop/background/mouse/opMouseWin.cpp | 50 +++++---------------------- 2 files changed, 15 insertions(+), 58 deletions(-) diff --git a/libop/background/mouse/opMouseDx.cpp b/libop/background/mouse/opMouseDx.cpp index b42e576..41cb05a 100644 --- a/libop/background/mouse/opMouseDx.cpp +++ b/libop/background/mouse/opMouseDx.cpp @@ -181,16 +181,11 @@ long opMouseDx::MoveToEx(int x, int y, int w, int h) long opMouseDx::LeftClick() { - long ret = 0, ret2 = 0; - - ///ret=::PostMessage(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y)); - ret = ::SendMessageTimeout(_hwnd, OP_WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y), SMTO_BLOCK, 2000, nullptr); - //ret = ::SendNotifyMessage(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y)); + long r1, r2; + r1 = LeftDown(); ::Delay(MOUSE_DX_DELAY); - //ret = ::SendMessage(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y)); - ret2 = ::SendMessageTimeout(_hwnd, OP_WM_LBUTTONUP, 0, MAKELPARAM(_x, _y), SMTO_BLOCK, 2000, nullptr); - - return ret && ret2 ? 1 : 0; + r2 = LeftUp(); + return r1 & r2 ? 1 : 0; } long opMouseDx::LeftDoubleClick() @@ -249,15 +244,11 @@ long opMouseDx::MiddleUp() long opMouseDx::RightClick() { - long ret = 0; long r1, r2; - - r1 = ::SendMessage(_hwnd, OP_WM_RBUTTONDOWN, MK_RBUTTON, MAKELPARAM(_x, _y)); + r1 = RightDown(); ::Delay(MOUSE_DX_DELAY); - r2 = ::SendMessage(_hwnd, OP_WM_RBUTTONUP, MK_RBUTTON, MAKELPARAM(_x, _y)); - ret = r1 == 0 && r2 == 0 ? 1 : 0; - - return ret; + r2 = RightUp(); + return r1 & r2 ? 1 : 0; } long opMouseDx::RightDown() diff --git a/libop/background/mouse/opMouseWin.cpp b/libop/background/mouse/opMouseWin.cpp index fbd63f7..c1e26c0 100644 --- a/libop/background/mouse/opMouseWin.cpp +++ b/libop/background/mouse/opMouseWin.cpp @@ -132,39 +132,20 @@ long opMouseWin::MoveToEx(int x, int y, int w, int h) { } long opMouseWin::LeftClick() { - long ret = 0, ret2 = 0; + long r1, r2; + r1 = LeftDown(); switch (_mode) { case INPUT_TYPE::IN_NORMAL: { - INPUT Input = { 0 }; - // left down - Input.type = INPUT_MOUSE; - Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN; - ret = ::SendInput(1, &Input, sizeof(INPUT)); - ::Delay(MOUSE_NORMAL_DELAY); - // left up - ::ZeroMemory(&Input, sizeof(INPUT)); - Input.type = INPUT_MOUSE; - Input.mi.dwFlags = MOUSEEVENTF_LEFTUP; - ret2 = ::SendInput(1, &Input, sizeof(INPUT)); + ::Delay(MOUSE_NORMAL_DELAY); break; } - case INPUT_TYPE::IN_WINDOWS: { - ret = ::SendMessageTimeout(_hwnd, WM_LBUTTONDOWN, 0, MAKELPARAM(_x, _y), SMTO_BLOCK, 2000, nullptr); ::Delay(MOUSE_WINDOWS_DELAY); - ret = ::SendMessageTimeout(_hwnd, WM_LBUTTONUP, 0, MAKELPARAM(_x, _y), SMTO_BLOCK, 2000, nullptr); - ///ret=::PostMessage(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y)); - //ret = ::SendMessageTimeout(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y), SMTO_BLOCK, 2000, nullptr); - //ret = ::SendNotifyMessage(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y)); - //::Sleep(100); - //ret = ::SendMessage(_hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(_x, _y)); - //ret2=::SendMessageTimeout(_hwnd, WM_LBUTTONUP, 0, MAKELPARAM(_x, _y), SMTO_BLOCK, 2000, nullptr); - //ret2 = ::SendMessage(_hwnd, WM_LBUTTONUP, 0, MAKELPARAM(_x, _y)); - //::SendMessage(_hwnd, WM_CAPTURECHANGED, 0, 0); break; } } - return ret && ret2 ? 1 : 0; + r2 = LeftUp(); + return r1 && r2 ? 1 : 0; } long opMouseWin::LeftDoubleClick() { @@ -286,35 +267,20 @@ long opMouseWin::MiddleUp() { long opMouseWin::RightClick() { - long ret = 0; long r1, r2; + r1 = RightDown(); switch (_mode) { case INPUT_TYPE::IN_NORMAL: { - INPUT Input = { 0 }; - // left down - Input.type = INPUT_MOUSE; - Input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN; - r1 = ::SendInput(1, &Input, sizeof(INPUT)); ::Delay(MOUSE_NORMAL_DELAY); - // left up - ::ZeroMemory(&Input, sizeof(INPUT)); - Input.type = INPUT_MOUSE; - Input.mi.dwFlags = MOUSEEVENTF_RIGHTUP; - r2 = ::SendInput(1, &Input, sizeof(INPUT)) ; - ret = r1 > 0 && r2 > 0 ? 1 : 0; break; } - case INPUT_TYPE::IN_WINDOWS: { - r1 = ::SendMessageTimeout(_hwnd, WM_RBUTTONDOWN, MK_RBUTTON, MAKELPARAM(_x, _y), SMTO_BLOCK, 2000, nullptr); ::Delay(MOUSE_WINDOWS_DELAY); - r2 = ::SendMessageTimeout(_hwnd, WM_RBUTTONUP, MK_RBUTTON, MAKELPARAM(_x, _y), SMTO_BLOCK, 2000, nullptr); - ret = r1 == 0 && r2 == 0 ? 1 : 0; break; } - } - return ret; + r2 = RightUp(); + return r1 && r2 ? 1 : 0; } long opMouseWin::RightDown()