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


Click here to return to the 'Create identical tiled windows in most apps via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create identical tiled windows in most apps via AppleScript
Authored by: raffar on Jun 22, '07 06:20:38AM
Here is a modification. I added options to allow right and left margins to be set independently. If these properties are set to 0, then default to previous behaviour. I also needed to add some height to correct for the menubar on my system. And lastly, this doesn't seem to work with Firefox. Anyone have any idea why? (Firefox does not seem to be responding to the "tell window x" directive.)
property maxWindowWidth : 1000
property menubarCorrection : 14 -- menubar height
property leftSideMarginDefault : 100 -- default position from left to start cascade. If 0 will default to half of available screen width minus maxWindowWidth
property rightSideMarginDefault : 200 -- default position from left to start cascade. If 0 will default to half of available screen width minus maxWindowWidth
-- therefore, if both leftSideMarginDefault and rightSideMarginDefault are 0, then center windows


tell application "Finder"
	set screenSize to bounds of window of desktop
	set availScreenWidth to item 3 of screenSize
	set availScreenHeight to item 4 of screenSize
end tell

tell application "System Events"
	set dockProps to property list file "~/Library/Preferences/com.apple.dock.plist"
	set dockSide to the value of the property list item "orientation" of dockProps
	set dockTileSize to the value of the property list item "tilesize" of dockProps
end tell

if dockSide is "bottom" then
	set availScreenHeight to availScreenHeight - (dockTileSize + 10)
end if

if leftSideMarginDefault is equal to 0 then
	set leftSideMargin to (availScreenWidth - maxWindowWidth) / 2
else
	set leftSideMargin to leftSideMarginDefault
end if

if rightSideMarginDefault is equal to 0 then
	set rightSideMargin to (availScreenWidth - maxWindowWidth) / 2
else
	set rightSideMargin to rightSideMarginDefault
end if

tell application "System Events"
	set myFrontMost to name of first item of (processes whose frontmost is true)
end tell

if myFrontMost is "Finder" then
	set myTopCorr to 22
else
	set myTopCorr to menubarCorrection
end if

try
	tell application myFrontMost
		set allWindows to (every window where visible is true)
		set n to count of allWindows
		set windowOffset to 0
		repeat with x from 1 to n
			set windowOffset to 20 * (x - 1)
			tell window x
				set bounds to {leftSideMargin + windowOffset, 30 + myTopCorr + windowOffset, (availScreenWidth - rightSideMargin) + windowOffset, availScreenHeight - (n + 1 - x) * 20}
			end tell
			set x to x + 1
			if x is equal to (n + 1) then exit repeat
		end repeat
	end tell
end try



[ Reply to This | # ]