Help With Variable Boundaries Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Noo0B
Posts: 73
Joined: 26 Jan 2018, 19:54

Help With Variable Boundaries

01 Jul 2018, 01:14

Hi,
Thanks for reading.
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!
gregster
Posts: 2658
Joined: 30 Sep 2013, 06:48

Re: Help With Variable Boundaries  Topic is solved

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)
Noo0B
Posts: 73
Joined: 26 Jan 2018, 19:54

Re: Help With Variable Boundaries

01 Jul 2018, 02:06

Thanks again for the reply and solution!
Best regards!

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], chrispage, dathan_neal, Google [Bot], malcev, Odius, sn0skier, teadrinker and 181 guests