我希望在点击右键时创建一个控制台,
鼠标向下移动
我试过这段代码,
bool MouseMove(int x, int y)
{
INPUT input;
input.type = INPUT_MOUSE;
input.mi.mouseData = 0;
input.mi.time = 0;
input.mi.dx = x;
input.mi.dy = y;
input.mi.dwFlags = MOUSEEVENTF_MOVE;
SendInput(1, &input, sizeof(input));
return true;
}
HWND hWnd;
HHOOK hMSHook;
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode >= HC_ACTION)
{
if (wParam == WM_RBUTTONUP)
{
MouseMove(0, 10);
return 1;
}
}
return CallNextHookEx(hKBHook, nCode, wParam, lParam);
}
int _tmain() {
hWnd = ::GetConsoleWindow();
ShowWindow(hWnd, 0);
HMODULE hInstance = GetModuleHandle(NULL);
hMSHook = SetWindowsHookEx(WH_MOUSE_LL, MouseProc, hInstance, NULL);
MSG Msg;
while (GetMessage(&Msg, NULL, 0, 0)) { DispatchMessage(&Msg); }
return 0;
}
它工作正常,但如果我尝试几次,
导致滞后(挣扎,缓慢,迟滞)
有人知道如何解决它吗?