gpt4 book ai didi

c++ - 输入_鼠标 : mouse does not move with given dx/dy values

转载 作者:行者123 更新时间:2023-11-28 08:07:38 24 4
gpt4 key购买 nike

我正在使用 INPUT 移动鼠标来设置光标位置。这很好,只是我不能使用屏幕值来移动光标。如果我想将光标设置为从 0 到 1680,我必须使用 1680*0.66 作为 dx 值来获得正确的位置(在游戏内或桌面上)。

(我使用 mousemove,因为我在游戏中设置光标位置,绝对定位在那里不起作用。我有两个屏幕,一个是 1680 宽,另一个是 1280)

知道为什么我必须使用这个因素或它来自哪里吗?谢谢。

#define MOUSE_MOVE_FACTOR 0.6619

//Set mouse pos:
void setMousePos(int iX, int iY){


iX = (int)((double)iX*MOUSE_MOVE_FACTOR);
iY = (int)((double)iY*MOUSE_MOVE_FACTOR);


INPUT *buffer = new INPUT[1];

buffer->type = INPUT_MOUSE;
buffer->mi.dx = iX;
buffer->mi.dy = iY;
buffer->mi.mouseData = 0;
buffer->mi.dwFlags = MOUSEEVENTF_MOVE;
buffer->mi.time = 0;
buffer->mi.dwExtraInfo = 0;

SendInput(1,buffer,sizeof(INPUT));

Sleep(100 + (rand() % 50));

}

最佳答案

可能与鼠标加速有关。禁用它会导致不同的鼠标位置。

关于c++ - 输入_鼠标 : mouse does not move with given dx/dy values,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9946871/

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