Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Tile Safari windows via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Tile Safari windows via AppleScript
Authored by: lxmorj on Dec 29, '06 01:55:35PM

I made a few adjustments: this will keep the Dock in mind, but only if it is on the bottom or the right. I haven't yet worked out what to do when its on the left.

tell application "Safari"
-- For some reason Safari has two invisible windows
set allWindows to (every window where visible is true)
set n to count of allWindows
-- Determine screen size of your machine, factoring in the Dock
set screenWidth to do JavaScript "screen.availWidth" in document 1
set screenHeight to do JavaScript "screen.availHeight" in document 1
-- Dividing by zero is bad
if n is equal to 0 then return
-- Determine each window's width
set windowWidth to (screenWidth / n)
set x to 1
-- Position each window in turn
repeat
tell window x
-- 21 is the size of the Menu Bar (for 10.4 at least)
set bounds to {windowWidth * (x - 1), 21, windowWidth * x, screenHeight}
end tell
set x to x + 1
if x is equal to (n + 1) then exit repeat
end repeat
end tell



[ Reply to This | # ]