Search code examples
autohotkey

How to reformulating a formula to another in AHK?


#If WinActive("Program Manager ahk_class Progman")
~LButton::
CoordMode, Mouse, screen
MouseGetPos, x,y
if (x > 100 and x < 200 and y > 300 and y < 400){
     SoundBeep, 1000
}
#If

I'd like to reformulate this formula (x > 100 and x < 200 and y > 300 and y < 400) to this (100 < x < 200 and 300 < y < 400).

The formula in the script above (x > 100 and x < 200 and y > 300 and y < 400) works well but the desired formula (100 < x < 200 and 300 < y < 400 ) doesn't work for me.

Does anyone know why the desired formula doesn't work?

Please help! I'll appreciated, Thanks.


Solution

  • The expression, as you're writing it, cannot be interpreted by AutoHotKey. An alternative would be to use the "BETWEEN" operator (though I personally don't prefer it ) nested.

    #If WinActive("Program Manager ahk_class Progman")
    ~LButton::
    CoordMode, Mouse, screen
    MouseGetPos, x,y
    If x between 100 and 200
        If  y between 300 and 400
            SoundBeep, 1000
    #If