Blockinput Alternative

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hemsith14_
Posts: 296
Joined: 07 Nov 2020, 08:37

Blockinput Alternative

Post by hemsith14_ » 13 Aug 2022, 09:49

Hey
I'm looking for an alternative to Blockinput mousemove, as it's not completely blocking user mouse movement while "MouseMove" is in progress.
The normal Blockinput is safer, but it also causes some keys to get stuck if released while it's on, so I'm looking for an alternative that will stop only the mouse.

Any help will be appreciated

wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Blockinput Alternative

Post by wetware05 » 13 Aug 2022, 10:53

:wave:

Here are some alternatives: viewtopic.php?f=76&t=107272

hemsith14_
Posts: 296
Joined: 07 Nov 2020, 08:37

Re: Blockinput Alternative

Post by hemsith14_ » 13 Aug 2022, 12:13

It's blocking mouse move completely there, and I'm looking for something that will allow it and only prevent input

wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Blockinput Alternative

Post by wetware05 » 13 Aug 2022, 13:24

Hi.

In the help about MouseMove (https://lexikos.github.io/v2/docs/commands/MouseMove.htm#Remarks) there is the possibility of a DllCall call that does work with the function created by Rohwedder, in viewtopic.php?f=76&t=107272, I imagine that it has to be an equivalent to clicking.

In the script I have put two keyboard shortcuts to lock and unlock, and another to move the mouse to a position, and it works even if the mouse is locked.

Code: Select all

^F3::
BlockInputMouse(True)
Return

^F6::
BlockInputMouse(False)
Return

^F9::
DllCall("SetCursorPos", "int", 100, "int", 400)
Return

BlockInputMouse(Block)
{ Static hHookMouse
	IF Block And !hHookMouse
		hHookMouse := SetWindowsHookEx(WH_MOUSE_LL := 14, RegisterCallback("True"))
	Else IF !Block And hHookMouse
		UnhookWindowsHookEx(hHookMouse), hHookMouse := False
}True() {
	Return, True
}SetWindowsHookEx(idHook, pfn) {
	Return DllCall("SetWindowsHookEx", "int", idHook, "Uint"
	, pfn, "Uint", DllCall("GetModuleHandle", "Str"), "Uint", 0)
}UnhookWindowsHookEx(hHook) {
	Return DllCall("UnhookWindowsHookEx", "Uint", hHook)
}

hemsith14_
Posts: 296
Joined: 07 Nov 2020, 08:37

Re: Blockinput Alternative

Post by hemsith14_ » 13 Aug 2022, 16:19

I'm using a relative mousemove, how can I do that with that DLL function?

wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Blockinput Alternative

Post by wetware05 » 13 Aug 2022, 17:36

I do not know much. That is why I make scripts based on such knowledge. You can use WinGetPos to find out the position and size of the current window (which I assume is why you use relative mouse position), while also finding out the size of the monitor, and you have to figure out how to do the calculation of the relative position of the window.

I'm sure someone who knows more than me will give you an easier solution.

Post Reply

Return to “Ask for Help (v1)”