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

1k views Asked by At

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? I tried the sleep command but that just makes it not move smooth rather very robotic. My code:

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

There are 1 answers

0
JorgTV On BEST ANSWER

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. 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)