How to disable mouse

Get help with using AutoHotkey and its commands and hotkeys
renArD
Posts: 22
Joined: 17 Feb 2020, 18:23

How to disable mouse

23 Feb 2021, 09:59

Hi everyone,

I know the title looks obvious. And that why it's difficult to find relevant information in my case (search key words always drive to same subjects).

I'd like to (temporally) totally disable the mouse. I don't mean "prevent the user from using it" neither "hide the cursor", which I already manage to do with this grabbed code :

Code: Select all

BlockInput, On
MouseGetPos, , , hwnd
Gui Cursor:+Owner%hwnd%
BlockInput MouseMove
DllCall("ShowCursor", Int,0)	

Code: Select all

BlockInput, Off
BlockInput MouseMoveOff
DllCall("ShowCursor", Int,1)	
The fact is the mouse cursor (even if hidden, even if I can't move it) still exists. That's why things under the cursor still react to it (pop-ups because mouse over).

That's why I'm wondering how to completely disable the mouse (and the enable it again !). I mean that it shouldn't exist any more.

I hope I've been clear and I didn't miss obvious ways to do.

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

Re: How to disable mouse

23 Feb 2021, 10:23

How about moving it to where it won’t be over anything like the corner of the screen before you block and hide it?
renArD
Posts: 22
Joined: 17 Feb 2020, 18:23

Re: How to disable mouse

23 Feb 2021, 10:34

Thanks for your prompt reply.
I already tried it but :
- I have to be sure that nothing will react where I put the cursor
- I have strange difficulties to set back the cursor to original position (I might open an other thread for that but up to now I don't know how to make it fail for sure)
That's why I'd like to achieve my goal by an other way :)
User avatar
boiler
Posts: 6883
Joined: 21 Dec 2014, 02:44

Re: How to disable mouse

23 Feb 2021, 10:53

It should be straightforward to move it back to its original position:

Code: Select all

CoordMode, Mouse, Screen

; your code to block and hide mouse here

MouseGetPos, PrevX, PrevY
MouseMove, 0, 0, 0

; your code to be executed while mouse is off here

MouseMove, PrevX, PrevY, 0

; your code to unblock and show mouse here
renArD
Posts: 22
Joined: 17 Feb 2020, 18:23

Re: How to disable mouse

23 Feb 2021, 11:13

Thanks
It's what I did but I wonder how MouseMove really does it. I think it does "move" and not just "position" the cursor. I mean it has a trajectory between the current position and the goal position. The fact is I run multiple screens and sometimes, between screens, your cursor is kind of "blocked" and you have to slide it slightly to "where the screens are really neighbours" (or any other Windows behaviour in the corners of the screen). This kind of "wall" prevents the cursor to go straight from A to B, so it is slightly deviated. I hope I'm clear !
User avatar
boiler
Posts: 6883
Joined: 21 Dec 2014, 02:44

Re: How to disable mouse

23 Feb 2021, 13:19

I’m sort of understanding what you’re saying. I don’t know how to actually remove the mouse pointer rather than just disabling it and hiding it. It may be that Windows doesn’t allow that, but others may know if it can be done and how.
renArD
Posts: 22
Joined: 17 Feb 2020, 18:23

Re: How to disable mouse

23 Feb 2021, 14:34

Thanks for trying!
I hope someone will know and tell me :)
renArD
Posts: 22
Joined: 17 Feb 2020, 18:23

Re: How to disable mouse

01 Mar 2021, 08:00

May I put this thread up ? Unfortunately it isn't solved yet. Thanks for all who read and think about it :)
renArD
Posts: 22
Joined: 17 Feb 2020, 18:23

Re: How to disable mouse

04 Mar 2021, 04:45

Hi,
Since my issue was the "screen border walls", I chose to move the cursor only in the current screen. To do so, I detect the coordinates of the top left corner of the screen where the mouse is (sorry English isn't my native language ;) ) and then move the cursor here. Code inspired by help and forum.

Code: Select all

MouseGetPos, X, Y
SysGet, MonitorCount, MonitorCount
Loop, %MonitorCount%
{
	SysGet, Monitor, Monitor, %A_Index%
	if (X>MonitorLeft and X<MonitorRight and Y>MonitorTop and Y<MonitorBottom)
		MouseMove MonitorLeft,MonitorTop,0
}
Thanks to all who helped in a way or another!

Return to “Ask For Help”

Who is online

Users browsing this forum: ahkn8b, ahknewguy, AHKStudent, Bing [Bot], bonswouar, mikeyww, milkygirl90, Quartz, TablePerson22, vmech and 37 guests