Disable mouse movement for all hotkeys in script Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
John1
Posts: 236
Joined: 11 May 2020, 11:54

Disable mouse movement for all hotkeys in script

Post by John1 » 08 Aug 2022, 05:47

I want to disable the mouse movement for all hotkeys in my script. (The mouse movement i send physically.) Can i disable it for all hotkeys in the whole script instead writing at every single hotkey "BlockInput, MouseMove" "BlockInput, MouseMoveOff"?
And i also would like to when disabled it for all enable it manually for some.

Thank you!

Code: Select all

1::
BlockInput, MouseMove
sleep, 200
MouseMove,30,20,0
sleep, 2000
BlockInput, MouseMoveOff
return

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Disable mouse movement for all hotkeys in script

Post by boiler » 08 Aug 2022, 06:05

Code: Select all

1::MouseMoveEx(30, 20)
2::MouseMoveEx(50, 70,, False) ; not blocked

MouseMoveEx(x, y, speed:=0, block:=True, preDelay:=200, postDelay:=2000) {
	if block
		BlockInput, MouseMove
	Sleep, preDelay
	MouseMove, x, y, speed
	Sleep, postDelay
	BlockInput, MouseMoveOff
}

John1
Posts: 236
Joined: 11 May 2020, 11:54

Re: Disable mouse movement for all hotkeys in script

Post by John1 » 08 Aug 2022, 07:38

@boiler
Thanks a lot for your reply!

I mean:
i have a lot of hotkeys in the script and want not change them manually. Can i change the default behavior of the script like adding something in the auto section. So it only disable mouse movement when one of the hotkeys is running.

Thank you!

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Disable mouse movement for all hotkeys in script  Topic is solved

Post by boiler » 08 Aug 2022, 09:51

John1 wrote: I mean:
i have a lot of hotkeys in the script and want not change them manually. Can i change the default behavior of the script like adding something in the auto section. So it only disable mouse movement when one of the hotkeys is running.
I doubt that’s possible. Depending on how you have your hotkeys set up, you may be able to replace all the MouseMove statements with calls to MouseMoveEx() if you know how to use the RegEx mode of find/replace in an editor like Notepad++ or VSCode.

John1
Posts: 236
Joined: 11 May 2020, 11:54

Re: Disable mouse movement for all hotkeys in script

Post by John1 » 10 Aug 2022, 12:23

@boiler Ok. Thank you again for your answer!

Post Reply

Return to “Ask for Help (v1)”