Disable Mouse Click in specific area of screen Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
wyw
Posts: 93
Joined: 12 Dec 2015, 19:11

Disable Mouse Click in specific area of screen

Post by wyw » 24 Oct 2020, 07:49

I need to disable mouse clicks in this small specific area, as can be seen on the screenshot. The symbols are located in the upper right corner on the screen. Basically I have to set it up so that I can't click on these icons.

This script here almost does the job, but I don't know how to find the right coordinates, that it only really turns off mouse clicks in this particular area and not in all other areas:

Code: Select all

#NoTrayIcon
#Persistent
SetTimer, MouseCheck, 1 ;check every 100ms or however often


MouseCheck:
MouseGetPos, MouseX, MouseY


If MouseY < 90
{
	MouseMove, %MouseX%, 91
}

Return


Again, I basically want to make a "circle" around these symbols and insert the captured coordinates into the script, so that mouse clicks are not possible as long as you are inside the circle (coordinates), and as soon as you are outside the circle, mouse clicks work again.



Help would be appreciated. I don't know what to do at this point. :crazy:
Attachments
Screenshot_65.png
Screenshot_65.png (2.63 KiB) Viewed 1982 times

User avatar
mikeyww
Posts: 26936
Joined: 09 Sep 2014, 18:38

Re: Disable Mouse Click in specific area of screen  Topic is solved

Post by mikeyww » 24 Oct 2020, 08:17

Code: Select all

#If corner()
*LButton::
*RButton::
*MButton::
*XButton1::
*XButton2::Return
#If

corner() {
 cornr := False
 MouseGetPos, xpos, ypos
 margin := A_ScreenWidth - 200
 If xpos between %margin% and %A_ScreenWidth%
  If ypos between 1 and 200
   cornr := True
 Return cornr
}
The script blocks the button if the mouse is in a corner. You can change the numbers in the function.

Coordinates are relative to the active window unless you add CoordMode. If you do use the active window (relative coordinates), you'll probably want to use the window width instead of screen width, or something like that. You can also just use absoluate coordinates if that's better.

Another method is BlockInput, but that's trickier.

wyw
Posts: 93
Joined: 12 Dec 2015, 19:11

Re: Disable Mouse Click in specific area of screen

Post by wyw » 24 Oct 2020, 08:29

mikeyww wrote:
24 Oct 2020, 08:17

Code: Select all

#If corner()
*LButton::
*RButton::
*MButton::
*XButton1::
*XButton2::Return
#If

corner() {
 cornr := False
 MouseGetPos, xpos, ypos
 margin := A_ScreenWidth - 200
 If xpos between %margin% and %A_ScreenWidth%
  If ypos between 1 and 200
   cornr := True
 Return cornr
}
The script blocks the button if the mouse is in a corner. You can change the numbers in the function.

Coordinates are relative to the active window unless you add CoordMode. If you do use the active window (relative coordinates), you'll probably want to use the window width instead of screen width, or something like that. You can also just use absoluate coordinates if that's better.

Another method is that you can use BlockInput.
I can't thank you enough, sir. Thank you so much. You saved my day, man!

User avatar
mikeyww
Posts: 26936
Joined: 09 Sep 2014, 18:38

Re: Disable Mouse Click in specific area of screen

Post by mikeyww » 24 Oct 2020, 08:43

You are welcome.

Just an alternative method if needed here.

Code: Select all

corner() {
 CoordMode, Mouse
 MouseGetPos, xpos, ypos
 Return (xpos > A_ScreenWidth - 200 && ypos < 200)
}

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

Re: Disable Mouse Click in specific area of screen

Post by John1 » 08 Aug 2022, 07:55

@mikeyww

How can i disable mouse movement in a specific area of the screen? (physically mouse movement by hand)


Thank you!

Code: Select all

#if blockPos101([434,29], [434,29])

*LButton::
*RButton::
*MButton::
*XButton1::
*XButton2::
return

TAB::
MouseMove_(944,200)
return

#if
blockPos101(xy1, xy2) {
 MouseGetPos, xpos, ypos
 Return xpos >= xy1.1 && xpos <= xy2.1 && ypos >= xy1.2 && ypos <= xy2.2
}

User avatar
mikeyww
Posts: 26936
Joined: 09 Sep 2014, 18:38

Re: Disable Mouse Click in specific area of screen

Post by mikeyww » 08 Aug 2022, 08:07

You may want to have a look: viewtopic.php?f=18&t=85970

Post Reply

Return to “Ask for Help (v1)”