need help moving cursor smoothly.

hello everyone,

i am trying to make a code that moves the mouse left and right with a/d when holding shift (for bhopping in my own game)

though in my game you have to move left and right smoothly and with a constant pace/velocity

i have been trying things for like 2 months but i still haven't found any solution to make the mouse move smoothly across the screen.

i have tried adding an animation to the cursor but that didnt have a constant pace (it went a bit stuttery)

also if there is no animation (just like with steps) then you cant gain momentum in the game.

please can somebody help me with this code?

btw its not for cheating (a few ppl said it looked like it) but its for testing my own game

btw its ahk v1.

also dont mind mousewheel up and down.

here's the code. thank you

#Persistent
MouseSpeed := 100
MovementFrequency := 1000
SmoothInterval := Round(1000 / MovementFrequency)
ShiftDown := false
$Shift::
ShiftDown := true
SetTimer, MouseMoveLoop, % SmoothInterval
return
$Shift Up::
ShiftDown := false
SetTimer, MouseMoveLoop, Off
return
MouseMoveLoop:
if (ShiftDown) {
if GetKeyState("a", "P") {
SmoothMouseMove(-MouseSpeed, 0)
}
if GetKeyState("d", "P") {
SmoothMouseMove(MouseSpeed, 0)
}
if GetKeyState("w", "P") {
MouseMoveUp()
}
}
return
SmoothMouseMove(dx, dy) {
MouseGetPos, startX, startY
targetX := startX + dx
targetY := startY + dy
distance := Round(Sqrt(dx**2 + dy**2))
steps := Round(distance / 50)
stepX := dx / steps
stepY := dy / steps
Loop, % steps {
startX += stepX
startY += stepY
DllCall("SetCursorPos", "int", Round(startX), "int", Round(startY))
Sleep, SmoothInterval
}
}
MouseMoveUp() {
MouseGetPos, mouseX, mouseY
mouseY -= 20
DllCall("SetCursorPos", "int", mouseX, "int", mouseY)
}
WheelUp::SendInput, {1}
WheelDown::SendInput, {3}