我一直在尝试模拟一个过程中的一系列输入 . 我唯一没有成功的是鼠标移动 . 我在网上找到了最接近的赌注:
bool mouse_move(int x, int y)
{
INPUT input;
input.type = INPUT_MOUSE;
input.mi.mouseData = 0;
input.mi.time = 0;
input.mi.dx = x*(65536/GetSystemMetrics(SM_CXSCREEN));//x being coord in pixels
input.mi.dy = y*(65536/GetSystemMetrics(SM_CYSCREEN));//y being coord in pixels
input.mi.dwFlags = MOUSEEVENTF_MOVE;//MOUSEEVENTF_ABSOLUTE
SendInput(1, &input, sizeof(input));
return true;
}
我不理解在线解释的结构 . 无论我输入什么值,鼠标都会一直显示在屏幕的右下角(显然除了0) .
有可能通过 SetCursorPos()
是的,但是一旦我进入这个过程,那个功能就不再起作用了 . 我需要模拟它,好像用户正在输入鼠标移动,到目前为止 SendInput()
工作 . 我似乎无法弄清楚定位 .
1 回答
如果要将光标放在绝对坐标中,则必须添加更多标志:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms646273(v=vs.85).aspx