property numCols : 2 property screenWidth : 1280 property screenHeight : 854 -- If you don't want to hard-code your screen width, because eg. you use multiple screens with differing properties at different times, then uncomment the 2 lines below: --set screenWidth to word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Width") as number --set screenHeight to word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Height") as number set menubarHeight to 22 tell application "System Events" set frontApp to name of first application process whose frontmost is true end tell --some apps are wacky and put the windows higher for some reason, adjust for this bug. if (frontApp is equal to "Finder" or frontApp is equal to "Microsoft Entourage") then set menubarHeight to 44 end if --leave room for the Excel Toolbar if (frontApp is equal to "Microsoft Excel") then set menubarHeight to 55 end if try tell application frontApp -- We are going to not layout any windows that are invisible or that do not have a title set windowCount to count of (windows whose visible is true and name is not "") set allWindowCount to count of windows -- Special case is there's only one window if windowCount = 1 then set numRows to 1 set numCols to 1 else set numRows to round (ceil (windowCount / numCols)) end if -- skipWindow is for skipping over windows which are invisible or titleless set skipWindow to 0 repeat with j from 0 to numRows - 1 repeat with i from 0 to numCols - 1 -- If we've done all the windows, then just get out if (j * numCols + i + 1) > windowCount then exit repeat end if -- Get a handle to the window we might want to resize set theWindow to window (j * numCols + i + 1 + skipWindow) -- Check that the window is visible and titled -- if it's not, then skip it repeat while (visible of theWindow is false or name of theWindow is "") set skipWindow to skipWindow + 1 set theWindow to window (j * numRows + i + 1 + skipWindow) end repeat -- resize the window set bounds of theWindow to {Â round (i * screenWidth / numCols), Â menubarHeight + (round (j * (screenHeight - menubarHeight) / numRows)), Â round ((i * screenWidth / numCols) + (screenWidth / numCols)), Â round ((menubarHeight + (round (j * (screenHeight - menubarHeight) / numRows))) + (screenHeight - menubarHeight) / numRows) Â } end repeat end repeat end tell on error the error_message number the error_number display dialog "Error: " & the error_number & ". " & the error_message buttons {"OK"} default button 1 end try