答案1
我无法弄清楚如何在不对应用程序名称进行硬编码的情况下做到这一点,但是请尝试以下操作:
alias topleft move screenOriginX;screenOriginY screenSizeX/2;screenSizeY/2
alias topright move screenOriginX+screenSizeX/2;screenOriginY screenSizeX/2;screenSizeY/2
alias bottomleft move screenOriginX;screenOriginY+screenSizeY/2 screenSizeX/2;screenSizeY/2
alias bottomright move screenOriginX+screenSizeX/2;screenOriginY+screenSizeY/2 screenSizeX/2;screenSizeY/2
layout texteditquadrants 'TextEdit' ${topleft} | ${topright} | ${bottomleft} | ${bottomright}
bind 1:ctrl layout texteditquadrants
如果您只有一个屏幕,则可以使用如下 AppleScript:
tell application "Finder"
set {0, 0, w, h} to bounds of window of desktop
end tell
tell application "System Events" to tell (process 1 where frontmost is true)
set n to number of windows
if n > 4 then set n to 4
repeat with i from 1 to n
set p to item i of {{0, 22}, {w / 2, 22}, {w / 2, h / 2 + 11}, {w / 2, h / 2 + 11}}
set position of window i to p
set size of window i to {w / 2, h / 2 - 11}
end repeat
end tell
这将创建四个新的 TextEdit 窗口并将它们平铺在屏幕上:
tell application "Finder"
set {0, 0, w, h} to bounds of window of desktop
end tell
set ytop to 22
set yhalf to (h - 22) / 2
tell application "TextEdit"
close windows
repeat with i from 1 to 4
make new document
end repeat
set bounds of window 1 to {0, ytop, w / 2, yhalf}
set bounds of window 2 to {w / 2, ytop, w, yhalf}
set bounds of window 3 to {0, yhalf, w / 2, h}
set bounds of window 4 to {w / 2, yhalf, w, h}
end tell