Recovering off screen windows in Mac OS X

I constantly lose windows on OS X. I think it’s because sometimes I am connected to an external monitor so OS X gets confused when I am not. I found a great solution online that I would like to re-post here so that I never have to look for it again and I can help share it with the world. All credit goes to the author of the original article.

The solution is to pop open your Script Editor and run this Apple script:

-- Example list of processes to ignore: {"xGestures"} or {"xGestures", "OtherApp", ...}
property processesToIgnore : {}
 
-- Get the size of the Display(s), only useful if there is one display
-- otherwise it will grab the total size of both displays
tell application "Finder"
  set _b to bounds of window of desktop
  set screen_width to item 3 of _b
  set screen_height to item 4 of _b
end tell
 
tell application "System Events"
  set allProcesses to application processes
  set _results to ""
  repeat with i from 1 to count allProcesses
    set doIt to 1
    repeat with z from 1 to count processesToIgnore
      if process i = process (item z of processesToIgnore) then
        set doIt to 0
      end if
    end repeat
 
    if doIt = 1 then
      tell process i
        repeat with x from 1 to (count windows)
          set winPos to position of window x
          set _x to item 1 of winPos
          set _y to item 2 of winPos
 
          if (_x < 0 or _y < 0 or _x > screen_width or _y > screen_height) then
 
            set position of window x to {0, 22}
 
          end if
        end repeat
 
      end tell
    end if
  end repeat
end tell
No TweetBacks yet. (Be the first to Tweet this post)
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • MySpace
  • Slashdot
  • StumbleUpon
  • Technorati
  • TwitThis

If you enjoyed this post, make sure you subscribe to my RSS feed!

This entry was posted in Random, Software. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

2 Comments

  1. Nick
    Posted May 14, 2010 at 1:57 pm | Permalink

    That worked!

    Thanks

  2. simon
    Posted June 10, 2010 at 12:09 pm | Permalink

    beautiful…thanks

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">