Page 1 of 1

### Help With Variable Boundaries

Posted: 01 Jul 2018, 01:14
Hi,
I'm having a hard time coding for variable boundaries.
What I'm trying to do is to get a hotkey to reset it's Toggle if the mouse cursor is around the center of the screen.
Here's the relevant code I tried:

Code: Select all

``````#SingleInstance, force
CoordMode, Mouse
LowY:= A_ScreenHeight / 3
HighY:= A_ScreenHeight * 2/3
LowX:= A_ScreenWidth / 3
HighX:= A_ScreenWidth * 2 / 3

XButton1 & 1::
MouseGetPos, PosX, PosY
If (PosY between A_ScreenHeight / 3 and A_ScreenHeight * 2/3) {
If (PosX between A_ScreenWidth / 3 and A_ScreenWidth * 2 / 3)
Msgbox Inbound, X%posX% Y%PosY%
}
Return

XButton1 & 2::
MouseGetPos, PosX, PosY
If (PosY between LowY and HighY) {
If (PosX between LowX and HighX)
Msgbox Inbound, X%posX% Y%PosY%
}
Return

XButton1 & 3::
MouseGetPos, PosX, PosY
If PosY between LowY and HighY
If PosX between LowX and HighX
Msgbox Inbound, X%posX% Y%PosY%
Return

XButton1 & 4::
MouseGetPos, PosX, PosY
If PosY !<  LowY
if PosY !> HighY
If PosX !< LowX
if PosX !> HighX
Msgbox Inbound, X%posX% Y%PosY%
Return``````
Any Ideas on how to proceed?
Thanks in advance and kind regards!

### Re: Help With Variable Boundaries  Topic is solved

Posted: 01 Jul 2018, 01:36
https://autohotkey.com/docs/commands/If ... tm#Remarks:
Caution: The operators "between", "is", "in", and "contains" are not supported in expressions.
But this would do what you want:

Code: Select all

``if (PosY >= A_ScreenHeight / 3 and PosY <= A_ScreenHeight * 2/3)``

### Re: Help With Variable Boundaries

Posted: 01 Jul 2018, 02:06
Thanks again for the reply and solution!
Best regards!