Issues with MouseEvent not working as intended

Ask gaming related questions (AHK v1.1 and older)
MichaelAHK
Posts: 5
Joined: 15 Jun 2022, 09:24

Issues with MouseEvent not working as intended

Post by MichaelAHK » 30 Jun 2022, 07:39

My issue is that mouse event for moving my mouse never seems to work if you haven't moved your mouse in a while. This is especially bad considering how there is a very long delay between mouse movements for me.

Code: Select all

DllCall("mouse_event", uint, 1, int, 1200, int, 0)
This code is to turn a character in a game 180 degrees (Minecraft if you think it matters).

Here is my code for mouse event, and here is my full code if you are interested. I have tried calling another mouse event right before the one I want working so it thinks the mouse has moved, but it doesn't seem to be working. Any help would be appreciated!

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

Numpad2::
Send {Click, down}
Loop
{
Loop, 25
{
Send {w down}
Sleep, 20500
Send {w up}
Send {a down}
Sleep, 20500
Send {a up}
}
Sleep, 1000
DllCall("mouse_event", uint, 1, int, 1200, int, 0)

Loop, 25
{
Send {a down}
Sleep, 20500
Send {a up}
Send {w down}
Sleep, 20500
Send {w up}
}
sleep, 1000

DllCall("mouse_event", uint, 1, int, 1200, int, 0)
}
return

[Mod edit: Changed codebox tags from .txt format to default .ahk format]

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Issues with MouseEvent not working as intended

Post by swagfag » 16 Jul 2022, 12:56

MichaelAHK wrote:
30 Jun 2022, 07:39
never seems to work if you haven't moved your mouse in a while
even stranger things could happen when u dont stick to a function's signature - ur script may crash, ur computer may vanish, u never know
ure trying to call a 5-argument function(https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-mouse_event), yet are providing only the first 3

Post Reply

Return to “Gaming Help (v1)”