|
@@ -184,9 +184,18 @@ namespace GAssist
|
|
|
if ( !IsWindow(hwnd) )
|
|
|
return;
|
|
|
|
|
|
+ ::ShowWindow(hwnd, SW_SHOWNORMAL);
|
|
|
::SetForegroundWindow(hwnd); // 窗口前置才能单击成功;
|
|
|
+#if 0 // 使用Post或Send的方式,鼠标是不会显示出来的;
|
|
|
::PostMessage(hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(pt.x, pt.y));
|
|
|
::PostMessage(hwnd, WM_LBUTTONUP, 0, MAKELPARAM(pt.x, pt.y));
|
|
|
+#else
|
|
|
+ POINT ptScreen = pt;
|
|
|
+ ClientToScreen(hwnd, &ptScreen);
|
|
|
+ ::SetCursorPos(ptScreen.x, ptScreen.y); // 必须将鼠标定位到目标单击点;
|
|
|
+ mouse_event(MOUSEEVENTF_LEFTDOWN, ptScreen.x, ptScreen.y, 0, 0);
|
|
|
+ mouse_event(MOUSEEVENTF_LEFTUP, ptScreen.x, ptScreen.y, 0, 0);
|
|
|
+#endif
|
|
|
OutputDebugString(_T("-------------------发送MouseClick\n"));
|
|
|
Sleep(200);
|
|
|
}
|
|
@@ -196,8 +205,18 @@ namespace GAssist
|
|
|
if ( !IsWindow(hwnd) )
|
|
|
return;
|
|
|
|
|
|
- ::SendMessage(hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
|
|
|
- ::SendMessage(hwnd, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
|
|
|
+ ::ShowWindow(hwnd, SW_SHOWNORMAL);
|
|
|
+ ::SetForegroundWindow(hwnd); // 窗口前置才能单击成功;
|
|
|
+#if 0
|
|
|
+ ::PostMessage(hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
|
|
|
+ ::PostMessage(hwnd, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
|
|
|
+#else
|
|
|
+ POINT ptScreen = {x,y};
|
|
|
+ ClientToScreen(hwnd, &ptScreen);
|
|
|
+ ::SetCursorPos(ptScreen.x, ptScreen.y);
|
|
|
+ mouse_event(MOUSEEVENTF_LEFTDOWN, ptScreen.x, ptScreen.y, 0, 0);
|
|
|
+ mouse_event(MOUSEEVENTF_LEFTUP, ptScreen.x, ptScreen.y, 0, 0);
|
|
|
+#endif
|
|
|
Sleep(200);
|
|
|
}
|
|
|
|
|
@@ -206,7 +225,7 @@ namespace GAssist
|
|
|
if ( !IsWindow(hwnd) )
|
|
|
return;
|
|
|
|
|
|
- ::SendMessage(hwnd, WM_MOUSEMOVE, MK_LBUTTON, MAKELPARAM(pt.x, pt.y));
|
|
|
+ ::PostMessage(hwnd, WM_MOUSEMOVE, MK_LBUTTON, MAKELPARAM(pt.x, pt.y));
|
|
|
Sleep(200);
|
|
|
}
|
|
|
|
|
@@ -216,18 +235,18 @@ namespace GAssist
|
|
|
return;
|
|
|
|
|
|
//::SendMessage(hwnd, WM_MOUSEMOVE, MK_LBUTTON, lparam);
|
|
|
- ::SendMessage(hwnd, WM_MOUSEMOVE, MK_LBUTTON, MAKELPARAM(ptStart.x, ptStart.y));
|
|
|
+ ::PostMessage(hwnd, WM_MOUSEMOVE, MK_LBUTTON, MAKELPARAM(ptStart.x, ptStart.y));
|
|
|
Sleep(200);
|
|
|
|
|
|
#if 1
|
|
|
// 计算个中间点;
|
|
|
POINT ptMid = { (ptStart.x + ptEnd.x) / 2, (ptStart.y + ptEnd.y) / 2};
|
|
|
- ::SendMessage(hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(ptMid.x, ptMid.y));
|
|
|
+ ::PostMessage(hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(ptMid.x, ptMid.y));
|
|
|
Sleep(200);
|
|
|
#endif
|
|
|
|
|
|
//::SendMessage(hwnd, WM_MOUSEMOVE, MK_LBUTTON, lparam);
|
|
|
- ::SendMessage(hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(ptEnd.x, ptEnd.y));
|
|
|
+ ::PostMessage(hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(ptEnd.x, ptEnd.y));
|
|
|
Sleep(200);
|
|
|
}
|
|
|
|
|
@@ -238,18 +257,18 @@ namespace GAssist
|
|
|
return;
|
|
|
|
|
|
//::SendMessage(hwnd, WM_MOUSEMOVE, MK_LBUTTON, lparam);
|
|
|
- ::SendMessage(hwnd, WM_MOUSEMOVE, MK_LBUTTON, MAKELPARAM(ptStart.x, ptStart.y));
|
|
|
+ ::PostMessage(hwnd, WM_MOUSEMOVE, MK_LBUTTON, MAKELPARAM(ptStart.x, ptStart.y));
|
|
|
Sleep(200);
|
|
|
|
|
|
#if 1
|
|
|
// 计算个中间点;
|
|
|
POINT ptMid = { (ptStart.x + ptEnd.x) / 2, (ptStart.y + ptEnd.y) / 2};
|
|
|
- ::SendMessage(hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(ptMid.x, ptMid.y));
|
|
|
+ ::PostMessage(hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(ptMid.x, ptMid.y));
|
|
|
Sleep(200);
|
|
|
#endif
|
|
|
|
|
|
//::SendMessage(hwnd, WM_MOUSEMOVE, MK_LBUTTON, lparam);
|
|
|
- ::SendMessage(hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(ptEnd.x, ptEnd.y));
|
|
|
+ ::PostMessage(hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(ptEnd.x, ptEnd.y));
|
|
|
Sleep(200);
|
|
|
MouseClick(hwnd, ptEnd);
|
|
|
}
|
|
@@ -259,6 +278,8 @@ namespace GAssist
|
|
|
if ( !IsWindow(hwnd) )
|
|
|
return;
|
|
|
|
|
|
+ ::ShowWindow(hwnd, SW_SHOWNORMAL);
|
|
|
+ ::SetForegroundWindow(hwnd);
|
|
|
#if 0
|
|
|
MouseClick(hwnd, ptStart);
|
|
|
// 按下鼠标左键;
|
|
@@ -267,13 +288,35 @@ namespace GAssist
|
|
|
|
|
|
::SendMessage(hwnd, WM_MOUSEMOVE, 0, MAKELPARAM(ptEnd.x, ptEnd.y));
|
|
|
Sleep(200);
|
|
|
-#else
|
|
|
+#endif
|
|
|
+
|
|
|
+#if 1
|
|
|
+ POINT ptScreen = ptStart;
|
|
|
+ ClientToScreen(hwnd, &ptScreen);
|
|
|
+ ::SetCursorPos(ptScreen.x, ptScreen.y);
|
|
|
+
|
|
|
::PostMessage(hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(ptStart.x, ptStart.y));
|
|
|
+ Sleep(1200);
|
|
|
|
|
|
::PostMessage(hwnd, WM_MOUSEMOVE, MK_LBUTTON, MAKELPARAM(ptEnd.x, ptEnd.y));
|
|
|
-
|
|
|
+ Sleep(200);
|
|
|
::PostMessage(hwnd, WM_LBUTTONUP, 0, MAKELPARAM(ptEnd.x, ptEnd.y));
|
|
|
#endif
|
|
|
+
|
|
|
+#if 0
|
|
|
+ // 能成功拖动游戏里的东西。
|
|
|
+ POINT ptSStart = ptStart;
|
|
|
+ POINT ptSEnd = ptEnd;
|
|
|
+ ClientToScreen(hwnd, &ptSStart);
|
|
|
+ ClientToScreen(hwnd, &ptSEnd);
|
|
|
+ ::SetCursorPos(ptSStart.x, ptSStart.y);
|
|
|
+
|
|
|
+ mouse_event(MOUSEEVENTF_LEFTDOWN, ptSStart.x, ptSStart.y, 0, 0);
|
|
|
+ Sleep(1200);//必须暂停1秒左右,拖动才有效;
|
|
|
+ mouse_event(MOUSEEVENTF_MOVE, 100, 0, 0, 0);
|
|
|
+ Sleep(500);
|
|
|
+ mouse_event(MOUSEEVENTF_LEFTUP, ptSEnd.x, ptSEnd.y, 0, 0);
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
// 截图;
|