A 22 pixel border may sound like an unusual goal, but I just started using Edgies (oneriver.jp) which allows you to keep Stickies-like notes with tabs on the edges of the screen.
To keep the tabs from overlapping and obscuring windows and documents, I rewrote some scripts that I use frequently (like one that opens a tabbed Safari window in the left half of my screen) to maintain that border.
Then I started experimenting with all open windows. I handle Finder windows separately because I couldn’t work them into the section that deals with other applications without breaking the script. Some applications (Previews, for example, but I haven’t tried this with very many yet) don’t resond to the script, and I haven’t tried to script floating windows.
The script isn’t unduly resource intensive - run from the editor on a dozen windows it briefly (about 1 second) hit 6% - and I usually have only a few windows open at once, so I’m considering adding an “on idle” handler once I’m satisfied with it.
Any comments or suggestions would be appreciated.
Thanks,
j
tell application "Finder"
set runningApps to name of processes whose visible is true and name is not "Finder"
set {d1, d2, d3, d4} to (desktop's window's bounds)
end tell
--Non-Finder windows
repeat with anApp in runningApps
tell application anApp
try
set everyWindow to (every window whose visible is true)
repeat with theWindow in everyWindow
set {b1, b2, b3, b4} to get bounds of theWindow
if b1 < 22 then
set b1 to 22
set bounds of theWindow to {b1, b2, b3, b4}
end if --b1 < 22 then
if b2 < 44 then
set b2 to 44
set bounds of theWindow to {b1, b2, b3, b4}
end if --b2 < 44 then
if (d3 - b3) < 22 then
set b3 to (d3 - 22)
set bounds of theWindow to {b1, b2, b3, b4}
end if --(d3 - b3) < 22 then
if (d4 - b4) < 22 then
set b4 to (d4 - 22)
set bounds of theWindow to {b1, b2, b3, b4}
end if --(d4 - b4) < 22 then
end repeat --with theWindow in everyWindow
end try
end tell --application anApp
end repeat --with anApp in runningApps
--Finder windows
tell application "Finder"
set {d1, d2, d3, d4} to (desktop's window's bounds)
set everyWindow to every window whose visible is true
repeat with theWindow in everyWindow
set {b1, b2, b3, b4} to get bounds of theWindow
if b1 < 22 then
set b1 to 22
set bounds of theWindow to {b1, b2, b3, b4}
end if --b1 < 22 then
if b2 < 66 then
set b2 to 66
set bounds of theWindow to {b1, b2, b3, b4}
end if --b2 < 66 then
if (d3 - b3) < 22 then
set b3 to (d3 - 22)
set bounds of theWindow to {b1, b2, b3, b4}
end if --(d3 - b3) < 22 then
if (d4 - b4) < 22 then
set b4 to (d4 - 22)
set bounds of theWindow to {b1, b2, b3, b4}
end if --(d4 - b4) < 22 then
end repeat --with theWindow in everyWindow
end tell --application "Finder"