Stop mouse movement during process

Ask gaming related questions (AHK v1.1 and older)
acnl
Posts: 95
Joined: 25 Nov 2017, 09:04

Stop mouse movement during process

Post by acnl » 02 Jun 2023, 19:52

The code below works really well but sometimes there are issues. If I move my mouse during the process, it will move the mouse and click the wrong thing and not where the specific mouse cursor locations are recorded. The other inputs are blocked but is it possible to stop all mouse movement when the press begins with Alt+a? Thank you!

Code: Select all

CoordMode Mouse

!a::
if on := !on {
    MouseGetPos x3, y3
    BlockInput, On  ; Block input to prevent manual mouse movement
    Send +{F3}
    Send {F2}
    MouseMove x1, y1, 0
} else {
    MouseGetPos x4, y4
    Send +{F3}
    Send {F4}
    MouseMove x2, y2, 0
    Send {Esc}
    Sleep 25
    Send {LButton}
    Send {F3}
    MouseMove x4, y4, 0
    Send f
    BlockInput, Off  ; Enable input after the process is complete
    Return
}

Send {Esc}
Sleep 25
Send {LButton}
Send {F3}
MouseMove x3, y3, 0
Send f
BlockInput, Off  ; Enable input after the process is complete
Return

+F2::
MouseGetPos x1, y1
Return

+F4::
MouseGetPos x2, y2
Return

Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Stop mouse movement during process

Post by Rohwedder » 03 Jun 2023, 03:16

Hallo,
perhaps?:

Code: Select all

CoordMode Mouse

!a::
BlockInput, MouseMove
if on := !on {
    MouseGetPos x3, y3
    BlockInput, On  ; Block input to prevent manual mouse movement
    Send +{F3}
    Send {F2}
    MouseMove x1, y1, 0
} else {
    MouseGetPos x4, y4
    Send +{F3}
    Send {F4}
    MouseMove x2, y2, 0
    Send {Esc}
    Sleep 25
    Send {LButton}
    Send {F3}
    MouseMove x4, y4, 0
    Send f
    BlockInput, Off  ; Enable input after the process is complete
	BlockInput, MouseMoveOff
    Return
}

Send {Esc}
Sleep 25
Send {LButton}
Send {F3}
MouseMove x3, y3, 0
Send f
BlockInput, Off  ; Enable input after the process is complete
BlockInput, MouseMoveOff
Return

+F2::
MouseGetPos x1, y1
Return

+F4::
MouseGetPos x2, y2
Return
Edit: MouseMove(Off) error
Last edited by Rohwedder on 03 Jun 2023, 09:22, edited 1 time in total.

acnl
Posts: 95
Joined: 25 Nov 2017, 09:04

Re: Stop mouse movement during process

Post by acnl » 03 Jun 2023, 08:18

@Rohwedder

This works very well! But sometimes it will run the process and not end, so the mousemove does not turn off. This causes my mouse cursor to get stuck until I press alt+a to reset it. Strange, it should work without any issues. Not sure what else to try.

Rohwedder
Posts: 7630
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Stop mouse movement during process

Post by Rohwedder » 03 Jun 2023, 09:26

Script revised.

Post Reply

Return to “Gaming Help (v1)”