2012-11-01 70 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