简体   繁体   English

如何使用 win32api (mouseeventf_move) 改变鼠标移动速度

[英]How to change the mouse movement speed with win32api (mouseeventf_move)

So I basically have a python script set up that moves the mouse in a game to specific x and y coordinates, my question now is how can I make it so the mouse is moving slower, yet still smooth from point a to point b?所以我基本上设置了一个 python 脚本,可以将游戏中的鼠标移动到特定的 x 和 y 坐标,我现在的问题是如何才能使鼠标移动得更慢,但从 a 点到 b 点仍然平滑? I tried the sleep command but that just makes it not move smooth rather very robotic.我尝试了 sleep 命令,但这只是让它移动起来不流畅,而是非常机器人化。 My code:我的代码:

if keyboard.is_pressed("Alt"):  
              win32api.mouse_event(win32con.MOUSEEVENTF_MOVE, int(x), int(y), 0, 0)
              time.sleep(.02)  

I just found out how to do it.我刚刚知道怎么做。 You just have to call the WinAPI for calling the mouse and multiply it by the smoothing value.您只需调用 WinAPI 来调用鼠标并将其乘以平滑值即可。 The higher the smoothing value the faster it goes: It looks something like this:平滑值越高,它运行得越快:它看起来像这样:

win32api.mouse_event(win32con.MOUSEEVENTF_MOVE, int(x) * smoothing, int(y) * smoothing, 0, 0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM