I wrote two AppleScripts that arrange windows in Safari and Opera. The scripts don't just tile horizontally or vertically, but order browser windows in the most optimal way. The scripts automatically detect the screen resolution, and the number of open browser windows; they can arrange up to 12 separate windows. The Opera script, due to an Opera bug (perhaps?) has to be run twice.
Here's the Safari AppleScript:
################# Arrange_logically_Safari_windows:
-- Script by Julian (looiopnr/zec0ect/ristQws/pasurimi) 22.04.10
-- Purpose: Arrange logically Safari windows
-- Will detect automatically the screen resolution and the number of open Safari windows
-- Will arrange up to 12 windows.
tell application "Safari"
set open_windows to (every window where visible is true)
set n to count of open_windows
tell application "Finder"
set scr_size to bounds of window of desktop
set scr_width to item 3 of scr_size
set scr_height to item 4 of scr_size
end tell
set Compensation_A to 11
set Compensation_B to 14
set Compensation_C to 7
if n = 1 then
tell application "Safari"
activate
tell window 1
set bounds to {0, 0, scr_width, scr_height}
end tell
end tell
end if
if n = 2 then
tell application "Safari"
activate
tell window 1
set bounds to {0, 0, scr_width / 2, scr_height}
end tell
activate
tell window 2
set bounds to {scr_width / 2, 0, scr_width, scr_height}
end tell
end tell
end if
if n = 3 then
tell application "Safari"
activate
tell window 1
set bounds to {0, 0, scr_width / 2, scr_height}
end tell
activate
tell window 2
set bounds to {((scr_width / 4) * 2), 0, scr_width, (scr_height / 2) - Compensation_A}
end tell
activate
tell window 3
set bounds to {((scr_width / 4) * 2), (scr_height / 2) + Compensation_A, scr_width, scr_height}
end tell
end tell
end if
if n = 4 then
tell application "Safari"
activate
tell window 1
set bounds to {0, 0, ((scr_width / 4) * 2), (scr_height / 2) - Compensation_A}
end tell
activate
tell window 2
set bounds to {((scr_width / 4) * 2), 0, scr_width, (scr_height / 2) - Compensation_A}
end tell
activate
tell window 3
set bounds to {0, (scr_height / 2) + Compensation_A, ((scr_width / 4) * 2), scr_height}
end tell
activate
tell window 4
set bounds to {((scr_width / 4) * 2), (scr_height / 2) + Compensation_A, scr_width, scr_height}
end tell
end tell
end if
if n = 5 then
tell application "Safari"
activate
tell window 1
set bounds to {0, 0, ((scr_width / 4) * 2), (scr_height / 2) - Compensation_A}
end tell
activate
tell window 2
set bounds to {0, (scr_height / 2) + Compensation_A, ((scr_width / 4) * 2), scr_height}
end tell
activate
tell window 3
set bounds to {((scr_width / 4) * 2), 0, scr_width, (scr_height / 3) - Compensation_C}
end tell
activate
tell window 4
set bounds to {((scr_width / 4) * 2), (scr_height / 3) + Compensation_B, scr_width, ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 5
set bounds to {((scr_width / 4) * 2), ((scr_height / 3) * 2) + Compensation_C, scr_width, scr_height}
end tell
end tell
end if
if n = 6 then
tell application "Safari"
activate
tell window 1
set bounds to {0, 0, ((scr_width / 4) * 2), (scr_height / 3) - Compensation_C}
end tell
activate
tell window 3
set bounds to {0, (scr_height / 3) + Compensation_B, ((scr_width / 4) * 2), ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 5
set bounds to {0, ((scr_height / 3) * 2) + Compensation_C, ((scr_width / 4) * 2), scr_height}
end tell
activate
tell window 2
set bounds to {((scr_width / 4) * 2), 0, scr_width, (scr_height / 3) - Compensation_C}
end tell
activate
tell window 4
set bounds to {((scr_width / 4) * 2), (scr_height / 3) + Compensation_B, scr_width, ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 6
set bounds to {((scr_width / 4) * 2), ((scr_height / 3) * 2) + Compensation_C, scr_width, scr_height}
end tell
end tell
end if
if n = 7 then
tell application "Safari"
activate
activate
tell window 1
set bounds to {0, 0, (scr_width / 3), (scr_height / 2) - Compensation_A}
end tell
activate
tell window 2
set bounds to {(scr_width / 3), 0, ((scr_width / 3) * 2), (scr_height / 2) - Compensation_A}
end tell
activate
tell window 3
set bounds to {0, (scr_height / 2) + Compensation_A, (scr_width / 3), scr_height}
end tell
activate
tell window 4
set bounds to {(scr_width / 3), (scr_height / 2) + Compensation_A, ((scr_width / 3) * 2), scr_height}
end tell
activate
tell window 5
set bounds to {((scr_width / 3) * 2), 0, scr_width, (scr_height / 3) - Compensation_C}
end tell
activate
tell window 6
set bounds to {((scr_width / 3) * 2), (scr_height / 3) + Compensation_B, scr_width, ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 7
set bounds to {((scr_width / 3) * 2), ((scr_height / 3) * 2) + Compensation_C, scr_width, scr_height}
end tell
end tell
end if
if n = 8 then
tell application "Safari"
activate
activate
tell window 1
set bounds to {0, 0, (scr_width / 3), (scr_height / 2) - Compensation_A}
end tell
activate
tell window 2
set bounds to {0, (scr_height / 2) + Compensation_A, (scr_width / 3), scr_height}
end tell
activate
tell window 3
set bounds to {(scr_width / 3), 0, ((scr_width / 3) * 2), (scr_height / 3) - Compensation_C}
end tell
activate
tell window 4
set bounds to {(scr_width / 3), (scr_height / 3) + Compensation_B, ((scr_width / 3) * 2), ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 5
set bounds to {(scr_width / 3), ((scr_height / 3) * 2) + Compensation_C, ((scr_width / 3) * 2), scr_height}
end tell
activate
tell window 6
set bounds to {((scr_width / 3) * 2), 0, scr_width, (scr_height / 3) - Compensation_C}
end tell
activate
tell window 7
set bounds to {((scr_width / 3) * 2), (scr_height / 3) + Compensation_B, scr_width, ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 8
set bounds to {((scr_width / 3) * 2), ((scr_height / 3) * 2) + Compensation_C, scr_width, scr_height}
end tell
end tell
end if
if n = 9 then
tell application "Safari"
activate
activate
tell window 1
set bounds to {0, 0, (scr_width / 3), (scr_height / 3) - Compensation_C}
end tell
activate
tell window 2
set bounds to {0, (scr_height / 3) + Compensation_B, (scr_width / 3), ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 3
set bounds to {0, ((scr_height / 3) * 2) + Compensation_C, (scr_width / 3), scr_height}
end tell
activate
tell window 4
set bounds to {(scr_width / 3), 0, ((scr_width / 3) * 2), (scr_height / 3) - Compensation_C}
end tell
activate
tell window 5
set bounds to {(scr_width / 3), (scr_height / 3) + Compensation_B, ((scr_width / 3) * 2), ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 6
set bounds to {(scr_width / 3), ((scr_height / 3) * 2) + Compensation_C, ((scr_width / 3) * 2), scr_height}
end tell
activate
tell window 7
set bounds to {((scr_width / 3) * 2), 0, scr_width, (scr_height / 3) - Compensation_C}
end tell
activate
tell window 8
set bounds to {((scr_width / 3) * 2), (scr_height / 3) + Compensation_B, scr_width, ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 9
set bounds to {((scr_width / 3) * 2), ((scr_height / 3) * 2) + Compensation_C, scr_width, scr_height}
end tell
end tell
end if
if n = 10 then
tell application "Safari"
activate
activate
tell window 1
set bounds to {0, 0, (scr_width / 4), (scr_height / 2) - Compensation_A}
end tell
activate
tell window 2
set bounds to {(scr_width / 4), 0, ((scr_width / 4) * 2), (scr_height / 2) - Compensation_A}
end tell
activate
tell window 3
set bounds to {0, (scr_height / 2) + Compensation_A, (scr_width / 4), scr_height}
end tell
activate
tell window 4
set bounds to {(scr_width / 4), (scr_height / 2) + Compensation_A, ((scr_width / 4) * 2), scr_height}
end tell
activate
tell window 5
set bounds to {((scr_width / 4) * 2), 0, ((scr_width / 4) * 3), (scr_height / 3) - Compensation_C}
end tell
activate
tell window 6
set bounds to {((scr_width / 4) * 2), (scr_height / 3) + Compensation_B, ((scr_width / 4) * 3), ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 7
set bounds to {((scr_width / 4) * 2), ((scr_height / 3) * 2) + Compensation_C, ((scr_width / 4) * 3), scr_height}
end tell
activate
tell window 8
set bounds to {((scr_width / 4) * 3), 0, scr_width, (scr_height / 3) - Compensation_C}
end tell
activate
tell window 9
set bounds to {((scr_width / 4) * 3), (scr_height / 3) + Compensation_B, scr_width, ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 10
set bounds to {((scr_width / 4) * 3), ((scr_height / 3) * 2) + Compensation_C, scr_width, scr_height}
end tell
end tell
end if
if n = 11 then
tell application "Safari"
activate
activate
tell window 1
set bounds to {0, 0, ((scr_width / 4) * 2), (scr_height / 3) - Compensation_C}
end tell
activate
tell window 2
set bounds to {0, (scr_height / 3) + Compensation_B, (scr_width / 4), ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 3
set bounds to {0, ((scr_height / 3) * 2) + Compensation_C, (scr_width / 4), scr_height}
end tell
activate
tell window 4
set bounds to {(scr_width / 4), (scr_height / 3) + Compensation_B, ((scr_width / 4) * 2), ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 5
set bounds to {(scr_width / 4), ((scr_height / 3) * 2) + Compensation_C, ((scr_width / 4) * 2), scr_height}
end tell
activate
tell window 6
set bounds to {((scr_width / 4) * 2), 0, ((scr_width / 4) * 3), (scr_height / 3) - Compensation_C}
end tell
activate
tell window 7
set bounds to {((scr_width / 4) * 2), (scr_height / 3) + Compensation_B, ((scr_width / 4) * 3), ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 8
set bounds to {((scr_width / 4) * 2), ((scr_height / 3) * 2) + Compensation_C, ((scr_width / 4) * 3), scr_height}
end tell
activate
tell window 9
set bounds to {((scr_width / 4) * 3), 0, scr_width, (scr_height / 3) - Compensation_C}
end tell
activate
tell window 10
set bounds to {((scr_width / 4) * 3), (scr_height / 3) + Compensation_B, scr_width, ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 11
set bounds to {((scr_width / 4) * 3), ((scr_height / 3) * 2) + Compensation_C, scr_width, scr_height}
end tell
end tell
end if
if n = 12 then
tell application "Safari"
activate
activate
tell window 1
set bounds to {0, 0, (scr_width / 4), (scr_height / 3) - Compensation_C}
end tell
activate
tell window 2
set bounds to {0, (scr_height / 3) + Compensation_B, (scr_width / 4), ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 3
set bounds to {0, ((scr_height / 3) * 2) + Compensation_C, (scr_width / 4), scr_height}
end tell
activate
tell window 4
set bounds to {(scr_width / 4), 0, ((scr_width / 4) * 2), (scr_height / 3) - Compensation_C}
end tell
activate
tell window 5
set bounds to {(scr_width / 4), (scr_height / 3) + Compensation_B, ((scr_width / 4) * 2), ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 6
set bounds to {(scr_width / 4), ((scr_height / 3) * 2) + Compensation_C, ((scr_width / 4) * 2), scr_height}
end tell
activate
tell window 7
set bounds to {((scr_width / 4) * 2), 0, ((scr_width / 4) * 3), (scr_height / 3) - Compensation_C}
end tell
activate
tell window 8
set bounds to {((scr_width / 4) * 2), (scr_height / 3) + Compensation_B, ((scr_width / 4) * 3), ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 9
set bounds to {((scr_width / 4) * 2), ((scr_height / 3) * 2) + Compensation_C, ((scr_width / 4) * 3), scr_height}
end tell
activate
tell window 10
set bounds to {((scr_width / 4) * 3), 0, scr_width, (scr_height / 3) - Compensation_C}
end tell
activate
tell window 11
set bounds to {((scr_width / 4) * 3), (scr_height / 3) + Compensation_B, scr_width, ((scr_height / 3) * 2) + Compensation_C}
end tell
activate
tell window 12
set bounds to {((scr_width / 4) * 3), ((scr_height / 3) * 2) + Compensation_C, scr_width, scr_height}
end tell
end tell
end if
end tell### Arrange_logically_Opera_windows:
-- Script by Julian (looiopnr/zec0ect/ristQws/pasurimi) 22.04.10
-- Purpose: Arrange logically Opera windows
-- Will detect automatically the screen resolution and the number of open Opera windows
-- Will arrange logically up to 12 windows.
-- Due to a Opera bug(?) you have to run it twice.
tell application "Opera"
set open_windows to (every window)
set n to count of open_windows
tell application "Finder"
set scr_size to bounds of window of desktop
set scr_width to item 3 of scr_size
set scr_height to item 4 of scr_size
end tell
set Compensation_A to 33
set Compensation_B to 32
set Compensation_C to 34
set Compensation_D to 5
set Compensation_E to 27
if n = 1 then
tell application "Opera"
activate
tell window 1
set bounds to {0, 0, scr_width, scr_height}
end tell
end tell
end if
if n = 2 then
tell application "Opera"
activate
tell window 1
set bounds to {0, 0, scr_width / 2, scr_height}
end tell
activate
tell window 2
set bounds to {scr_width / 2, 0, scr_width, scr_height}
end tell
end tell
end if
if n = 3 then
tell application "Opera"
activate
tell window 1
set bounds to {0, 0, scr_width / 2, scr_height}
end tell
activate
tell window 2
set bounds to {((scr_width / 4) * 2), 0, scr_width, (scr_height / 2) - Compensation_A}
end tell
activate
tell window 3
set bounds to {((scr_width / 4) * 2), (scr_height / 2) + Compensation_A, scr_width, scr_height}
end tell
end tell
end if
if n = 4 then
tell application "Opera"
activate
tell window 1
set bounds to {0, 0, ((scr_width / 4) * 2), (scr_height / 2) - Compensation_A}
end tell
activate
tell window 2
set bounds to {((scr_width / 4) * 2), 0, scr_width, (scr_height / 2) - Compensation_A}
end tell
activate
tell window 3
set bounds to {0, (scr_height / 2) + Compensation_A, ((scr_width / 4) * 2), scr_height}
end tell
activate
tell window 4
set bounds to {((scr_width / 4) * 2), (scr_height / 2) + Compensation_A, scr_width, scr_height}
end tell
end tell
end if
if n = 5 then
tell application "Opera"
activate
tell window 1
set bounds to {0, 0, ((scr_width / 4) * 2), (scr_height / 2) - Compensation_A}
end tell
activate
tell window 2
set bounds to {0, (scr_height / 2) + Compensation_A, ((scr_width / 4) * 2), scr_height}
end tell
activate
tell window 3
set bounds to {((scr_width / 4) * 2), 0, scr_width, (scr_height / 3) - Compensation_B}
end tell
activate
tell window 4
set bounds to {((scr_width / 4) * 2), (scr_height / 3) + Compensation_C, scr_width, ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 5
set bounds to {((scr_width / 4) * 2), ((scr_height / 3) * 2) + Compensation_E, scr_width, scr_height}
end tell
end tell
end if
if n = 6 then
tell application "Opera"
activate
tell window 1
set bounds to {0, 0, ((scr_width / 4) * 2), (scr_height / 3) - Compensation_B}
end tell
activate
tell window 3
set bounds to {0, (scr_height / 3) + Compensation_C, ((scr_width / 4) * 2), ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 5
set bounds to {0, ((scr_height / 3) * 2) + Compensation_E, ((scr_width / 4) * 2), scr_height}
end tell
activate
tell window 2
set bounds to {((scr_width / 4) * 2), 0, scr_width, (scr_height / 3) - Compensation_B}
end tell
activate
tell window 4
set bounds to {((scr_width / 4) * 2), (scr_height / 3) + Compensation_C, scr_width, ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 6
set bounds to {((scr_width / 4) * 2), ((scr_height / 3) * 2) + Compensation_E, scr_width, scr_height}
end tell
end tell
end if
if n = 7 then
tell application "Opera"
activate
activate
tell window 1
set bounds to {0, 0, (scr_width / 3), (scr_height / 2) - Compensation_A}
end tell
activate
tell window 2
set bounds to {(scr_width / 3), 0, ((scr_width / 3) * 2), (scr_height / 2) - Compensation_A}
end tell
activate
tell window 3
set bounds to {0, (scr_height / 2) + Compensation_A, (scr_width / 3), scr_height}
end tell
activate
tell window 4
set bounds to {(scr_width / 3), (scr_height / 2) + Compensation_A, ((scr_width / 3) * 2), scr_height}
end tell
activate
tell window 5
set bounds to {((scr_width / 3) * 2), 0, scr_width, (scr_height / 3) - Compensation_B}
end tell
activate
tell window 6
set bounds to {((scr_width / 3) * 2), (scr_height / 3) + Compensation_C, scr_width, ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 7
set bounds to {((scr_width / 3) * 2), ((scr_height / 3) * 2) + Compensation_E, scr_width, scr_height}
end tell
end tell
end if
if n = 8 then
tell application "Opera"
activate
activate
tell window 1
set bounds to {0, 0, (scr_width / 3), (scr_height / 2) - Compensation_A}
end tell
activate
tell window 2
set bounds to {0, (scr_height / 2) + Compensation_A, (scr_width / 3), scr_height}
end tell
activate
tell window 3
set bounds to {(scr_width / 3), 0, ((scr_width / 3) * 2), (scr_height / 3) - Compensation_B}
end tell
activate
tell window 4
set bounds to {(scr_width / 3), (scr_height / 3) + Compensation_C, ((scr_width / 3) * 2), ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 5
set bounds to {(scr_width / 3), ((scr_height / 3) * 2) + Compensation_E, ((scr_width / 3) * 2), scr_height}
end tell
activate
tell window 6
set bounds to {((scr_width / 3) * 2), 0, scr_width, (scr_height / 3) - Compensation_B}
end tell
activate
tell window 7
set bounds to {((scr_width / 3) * 2), (scr_height / 3) + Compensation_C, scr_width, ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 8
set bounds to {((scr_width / 3) * 2), ((scr_height / 3) * 2) + Compensation_E, scr_width, scr_height}
end tell
end tell
end if
if n = 9 then
tell application "Opera"
activate
activate
tell window 1
set bounds to {0, 0, (scr_width / 3), (scr_height / 3) - Compensation_B}
end tell
activate
tell window 2
set bounds to {0, (scr_height / 3) + Compensation_C, (scr_width / 3), ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 3
set bounds to {0, ((scr_height / 3) * 2) + Compensation_E, (scr_width / 3), scr_height}
end tell
activate
tell window 4
set bounds to {(scr_width / 3), 0, ((scr_width / 3) * 2), (scr_height / 3) - Compensation_B}
end tell
activate
tell window 5
set bounds to {(scr_width / 3), (scr_height / 3) + Compensation_C, ((scr_width / 3) * 2), ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 6
set bounds to {(scr_width / 3), ((scr_height / 3) * 2) + Compensation_E, ((scr_width / 3) * 2), scr_height}
end tell
activate
tell window 7
set bounds to {((scr_width / 3) * 2), 0, scr_width, (scr_height / 3) - Compensation_B}
end tell
activate
tell window 8
set bounds to {((scr_width / 3) * 2), (scr_height / 3) + Compensation_C, scr_width, ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 9
set bounds to {((scr_width / 3) * 2), ((scr_height / 3) * 2) + Compensation_E, scr_width, scr_height}
end tell
end tell
end if
if n = 10 then
tell application "Opera"
activate
activate
tell window 1
set bounds to {0, 0, (scr_width / 4), (scr_height / 2) - Compensation_A}
end tell
activate
tell window 2
set bounds to {(scr_width / 4), 0, ((scr_width / 4) * 2), (scr_height / 2) - Compensation_A}
end tell
activate
tell window 3
set bounds to {0, (scr_height / 2) + Compensation_A, (scr_width / 4), scr_height}
end tell
activate
tell window 4
set bounds to {(scr_width / 4), (scr_height / 2) + Compensation_A, ((scr_width / 4) * 2), scr_height}
end tell
activate
tell window 5
set bounds to {((scr_width / 4) * 2), 0, ((scr_width / 4) * 3), (scr_height / 3) - Compensation_B}
end tell
activate
tell window 6
set bounds to {((scr_width / 4) * 2), (scr_height / 3) + Compensation_C, ((scr_width / 4) * 3), ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 7
set bounds to {((scr_width / 4) * 2), ((scr_height / 3) * 2) + Compensation_E, ((scr_width / 4) * 3), scr_height}
end tell
activate
tell window 8
set bounds to {((scr_width / 4) * 3), 0, scr_width, (scr_height / 3) - Compensation_B}
end tell
activate
tell window 9
set bounds to {((scr_width / 4) * 3), (scr_height / 3) + Compensation_C, scr_width, ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 10
set bounds to {((scr_width / 4) * 3), ((scr_height / 3) * 2) + Compensation_E, scr_width, scr_height}
end tell
end tell
end if
if n = 11 then
tell application "Opera"
activate
activate
tell window 1
set bounds to {0, 0, ((scr_width / 4) * 2), (scr_height / 3) - Compensation_B}
end tell
activate
tell window 2
set bounds to {0, (scr_height / 3) + Compensation_C, (scr_width / 4), ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 3
set bounds to {0, ((scr_height / 3) * 2) + Compensation_E, (scr_width / 4), scr_height}
end tell
activate
tell window 4
set bounds to {(scr_width / 4), (scr_height / 3) + Compensation_C, ((scr_width / 4) * 2), ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 5
set bounds to {(scr_width / 4), ((scr_height / 3) * 2) + Compensation_C, ((scr_width / 4) * 2), scr_height + Compensation_D}
end tell
activate
tell window 6
set bounds to {((scr_width / 4) * 2), 0, ((scr_width / 4) * 3), (scr_height / 3) - Compensation_E}
end tell
activate
tell window 7
set bounds to {((scr_width / 4) * 2), (scr_height / 3) + Compensation_C, ((scr_width / 4) * 3), ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 8
set bounds to {((scr_width / 4) * 2), ((scr_height / 3) * 2) + Compensation_E, ((scr_width / 4) * 3), scr_height}
end tell
activate
tell window 9
set bounds to {((scr_width / 4) * 3), 0, scr_width, (scr_height / 3) - Compensation_B}
end tell
activate
tell window 10
set bounds to {((scr_width / 4) * 3), (scr_height / 3) + Compensation_C, scr_width, ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 11
set bounds to {((scr_width / 4) * 3), ((scr_height / 3) * 2) + Compensation_E, scr_width, scr_height}
end tell
end tell
end if
if n = 12 then
tell application "Opera"
activate
activate
tell window 1
set bounds to {0, 0, (scr_width / 4), (scr_height / 3) - Compensation_B}
end tell
activate
tell window 2
set bounds to {0, (scr_height / 3) + Compensation_C, (scr_width / 4), ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 3
set bounds to {0, ((scr_height / 3) * 2) + Compensation_E, (scr_width / 4), scr_height}
end tell
activate
tell window 4
set bounds to {(scr_width / 4), 0, ((scr_width / 4) * 2), (scr_height / 3) - Compensation_B}
end tell
activate
tell window 5
set bounds to {(scr_width / 4), (scr_height / 3) + Compensation_C, ((scr_width / 4) * 2), ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 6
set bounds to {(scr_width / 4), ((scr_height / 3) * 2) + Compensation_E, ((scr_width / 4) * 2), scr_height}
end tell
activate
tell window 7
set bounds to {((scr_width / 4) * 2), 0, ((scr_width / 4) * 3), (scr_height / 3) - Compensation_B}
end tell
activate
tell window 8
set bounds to {((scr_width / 4) * 2), (scr_height / 3) + Compensation_C, ((scr_width / 4) * 3), ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 9
set bounds to {((scr_width / 4) * 2), ((scr_height / 3) * 2) + Compensation_E, ((scr_width / 4) * 3), scr_height}
end tell
activate
tell window 10
set bounds to {((scr_width / 4) * 3), 0, scr_width, (scr_height / 3) - Compensation_B}
end tell
activate
tell window 11
set bounds to {((scr_width / 4) * 3), (scr_height / 3) + Compensation_C, scr_width, ((scr_height / 3) * 2) + Compensation_D}
end tell
activate
tell window 12
set bounds to {((scr_width / 4) * 3), ((scr_height / 3) * 2) + Compensation_E, scr_width, scr_height}
end tell
end tell
end if
end tellMac OS X Hints
http://hints.macworld.com/article.php?story=2010042507472817