gpt4 book ai didi

C++ MOUSEEVENTF_MOVE 相对

转载 作者:太空狗 更新时间:2023-10-29 21:15:31 32 4
gpt4 key购买 nike

我正在尝试使用以下代码在屏幕上相对移动光标:

input.type = INPUT_MOUSE;
ZeroMemory(&input, sizeof(input));
input.mi.mouseData = 0;
input.mi.time = 0;
input.mi.dx = 20;
input.mi.dy = 20;
input.mi.dwExtraInfo = 0;
input.mi.dwFlags = MOUSEEVENTF_MOVE;
SendInput(1, &input, sizeof(input));

问题是,光标像这样移动(当前位置 | 新位置 [我使用“GetCursorPos()”函数获得坐标]):

0 0 | 41 41
41 41 | 108 108
108 108 | 174 174
174 174 | 241 241
241 241 | 307 307
307 307 | 374 374
374 374 | 441 441

有人可以帮我解决这个问题吗?

最佳答案

系统可能会合并鼠标移动,因为您没有指定 MOUSEEVENTF_MOVE_NOCOALESCE

更重要的是,您正在指定原始鼠标移动,它可以由系统进行调整,如 the documentation 中所述。 .

Relative mouse motion is subject to the effects of the mouse speed and the two-mouse threshold values. [...] If the specified distance along either the x or y axis is greater than the first mouse threshold value, and the mouse speed is not zero, the system doubles the distance. If the specified distance along either the x or y axis is greater than the second mouse threshold value, and the mouse speed is equal to two, the system doubles the distance that resulted from applying the first threshold test. It is thus possible for the system to multiply specified relative mouse movement along the x or y axis by up to four times.

关于C++ MOUSEEVENTF_MOVE 相对,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37544284/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com