Smoother/slower mouse movement in a game

Ask gaming related questions
Rok
Posts: 68
Joined: 11 Jan 2016, 08:50

Smoother/slower mouse movement in a game

15 Dec 2023, 10:49

I'm trying to make a simple hotkey for a smooth 180-turn in a first-person shooter, but the results I'm getting are either an instant movement/turn with:

Code: Select all

F1::
{
    MouseMove 400, 20, 1
}
Or weird circular movement at the character's feet with:

Code: Select all

F1::
{
    SendMode "Event"
    MouseMove 1, 1, 99
}
Notice the difference in the X and Y coords. The (400, 20) coordinates were adjusted correctly for a 180-turn, but the problem is that it's instant. On the other hand, when I try changing the — now default — SendMode from Input to Event and change the speed to anything slower than 1 (from 2 to 100), I get this weird unexpected movement, even with those (1, 1) coords. Play mode, on the other hand, just makes the script/hotkey unresponsive, or it just does nothing in-game.

I've also tried looping smaller mouse movements in Input mode, but the movement is too jittery and unnatural.

How can I get a smoother, non-instant mouse movement in this case?
User avatar
ElVerdaderoJuan
Posts: 8
Joined: 14 Dec 2023, 15:04
Contact:

Re: Smoother/slower mouse movement in a game

16 Dec 2023, 11:19

:ugeek: It turns out that apparently AutoHotkey didn't implement mouse speed well because even the examples in the documentation also work the same way. It is as if there was no delay. Not even with SetDefaultMouseSpeed
User avatar
gregster
Posts: 9224
Joined: 30 Sep 2013, 06:48

Re: Smoother/slower mouse movement in a game

16 Dec 2023, 11:31

ElVerdaderoJuan wrote:
16 Dec 2023, 11:19
It is as if there was no delay. Not even with SetDefaultMouseSpeed
In AHK v2, Sendinput is the default send mode, that's why you should use SendEvent mode if you want to use the Speed parameter (although this doesn't seem to solve the OP's issue):
https://www.autohotkey.com/docs/v2/lib/MouseMove.htm#Parameters wrote:Speed is ignored for SendInput/Play modes; they move the mouse instantaneously (though SetMouseDelay has a mode that applies to SendPlay). To visually move the mouse more slowly -- such as a script that performs a demonstration for an audience -- use SendEvent "{Click 100 200}" or SendMode "Event" (optionally in conjuction with BlockInput).
User avatar
Noitalommi_2
Posts: 393
Joined: 16 Aug 2023, 10:58

Re: Smoother/slower mouse movement in a game

19 Dec 2023, 23:10

@Rok

Hi,

you have to use Relative mode. "R"

Code: Select all

#Requires AutoHotkey >=2.0
#SingleInstance

SendMode "Event"

F1::MouseMove(-1000, 0, 100, "R") ; moves 1000 units left

;Some games use mouse acceleration, to counteract this, try to move the mouse in smaller steps
F2::{

	Loop 10
		MouseMove 100, 0, 100, "R" ; moves 1000 units right
}
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Smoother/slower mouse movement in a game

20 Dec 2023, 01:46

Yeah, I have to say that I didn’t understand why moving the mouse to absolute coordinates 400, 20 would execute a turn. Why would that make sense regardless of the starting position of the mouse? Depending on where the mouse was before executing that move, it could be a move straight up, it could be straight to the right, or straight to the left. It could be different diagonal movements. So I never understood the premise of this thread. It would make total sense to me if it were always a relative motion of the mouse no matter the position on the screen as Noitalommi_2 suggests.

Return to “Gaming Help (v2)”

Who is online

Users browsing this forum: vanove and 16 guests