2012-12-15 49 views
0

我想將特定應用程序的窗口移至確定的座標。設置包含單詞的窗口的位置

我已經做了一個原始的腳本,但我想以更優雅和功能的方式。它應該只移動其標題中包含確定單詞的窗口。也許我們應該在標題中創建一個帶有該詞的窗口列表,然後在它們之間循環以放置這些座標。

我該如何做到這一點?

這是我到目前爲止已經寫的:

tell application "System Events" 
    tell process "AppIT" 
     (* 
    {804, 368} 
{536, 368} 
{268, 368} 
{0, 368} 
{804, 22} 
{536, 22} 
{268, 22} 
{0, 22} 
*) 
     set position of window 1 to {0, 22} 
     set position of window 2 to {268, 22} 
     set position of window 3 to {536, 22} 
     set position of window 4 to {804, 22} 
     set position of window 5 to {0, 368} 
     set position of window 6 to {268, 368} 
     set position of window 7 to {536, 368} 
     set position of window 8 to {804, 368} 

     set position of window 9 to {0, 22} 
     set position of window 10 to {268, 22} 
     set position of window 11 to {536, 22} 
     set position of window 12 to {804, 22} 
     set position of window 13 to {0, 368} 
     set position of window 14 to {268, 368} 
     set position of window 15 to {536, 368} 
     set position of window 16 to {804, 368} 

     set position of window 17 to {0, 22} 
     set position of window 18 to {268, 22} 
     set position of window 19 to {536, 22} 
     set position of window 20 to {804, 22} 
     set position of window 21 to {0, 368} 
     set position of window 22 to {268, 368} 
     set position of window 23 to {536, 368} 
     set position of window 24 to {804, 368} 
    end tell 
end tell 

回答

1
tell application "System Events" 
    tell process "TextEdit" 
     set w to windows where title contains "text" 
     set position of item 1 of w to {0, 22} 
     set position of item 2 of w to {268, 22} 
    end tell 
end tell