Gather all windows to top left corner of main display

Alec Jacobson

November 02, 2010

weblog/

So far I prefer my cheapskate way, but here's another way to get all windows onto your main display. The downside is that it puts them all at the top left corner:
tell application "System Events" to set the visible of every process to true

tell application "System Events" to set theApps to (name of every process whose visible is true and name is not (my name as text))

repeat with theApp in theApps
	tell application theApp
		set i to 1
		repeat (window count) times
			set old_bounds to bounds of item i in windows
			set new_bounds to {0, 0, (item 3 of old_bounds) - (item 1 of old_bounds), (item 4 of old_bounds) - (item 2 of old_bounds)}
			set bounds of item i in windows to new_bounds
			set i to i + 1
		end repeat
	end tell
end repeat