2012-11-01 68 views
1

我想编写脚本,针对有多个窗口同时打开的应用程序。 当他们需要用户对它们执行操作时,它们中的一些会弹出到前台。是否有可能在后台移动窗口(不偷焦点)

然而,在前台每一个窗口,背后有许多人(背景)。 我想将特定的背景窗口移动到屏幕的不同位置。

我想知道这是否可能与苹果,但没有偷盗焦点;移动时他们不应该到达前台。

回答

1

开2个窗口(或更多)的Safari和尝试。它会将第二个窗口向右移动5个像素。此代码应该适用于您的应用程序,以及System Events知道的窗口,并可以重新定位其他应用程序的位置。请注意,Windows还有一个您可能想要使用的大小属性。

tell application "System Events" 
    tell process "Safari" 
     set theWindows to windows 
     if (count of theWindows) is greater than or equal to 2 then 
      set p to position of (item 2 of theWindows) 
      set position of window 2 to {(item 1 of p) + 5, item 2 of p} 
     end if 
    end tell 
end tell 
+0

要命!非常感谢 – KingBOB