Reputation: 10636
Hi I'm trying to make a macro that moves the active window between two positions, but only if its actual position is one of the both defined.
X1 := (0.0395839*A_ScreenWidth)
Y1 := (0.049074*A_ScreenHeight)
X2 := (0.341146*A_ScreenWidth)
Y2 := (0.085185*A_ScreenHeight)
F1:: WinMove, A,, X1, Y1 ; works
F2:: WinMove, A,, X2, Y2 ; works
F3:: ; doesn't work. What am I doing wrong here?
WinGetPos, Xa, Ya,,, A
If (Xa ="X1" AND Ya = "Y1")
WinMove, A,, X2, Y2
else
If (Xa = "X2" AND Ya = "Y2")
WinMove, A,, X1, Y1
return
Upvotes: -1
Views: 180
Reputation: 2682
What you were trying to do is Compare variable Xa with a the String value of "X1" and not the Value contained in the Variable X1. You need to remove the quotes, like so:
F3:: ; doesn't work. What am I doing wrong here?
WinGetPos, Xa, Ya,,, A
If (Xa == X1 AND Ya == Y1)
WinMove, A,, X2, Y2
else
If (Xa == X2 AND Ya == Y2)
WinMove, A,, X1, Y1
return
Upvotes: 1