在两个位置之间移动窗口

时间:2015-12-12 22:15:35

标签: autohotkey

您好我试图制作一个可以在两个位置之间移动活动窗口的宏, 但只有当它的实际位置是两者之一时才定义。

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

1 个答案:

答案 0 :(得分:1)

你要做的是将变量Xa与" X1"的字符串值进行比较。而不是变量X1中包含的值。您需要删除引号,如下所示:

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