So, you’ve got more than one screen? Life is good with all that wonderful screen real estate, then BAM… You end up back with just your main screen, but your applications have left their windows on those other displays, far out of your reach…
Let’s fix that. This little script simply goes and tells all of your applications to get their act together, to move their window’s to the main display.
You’ll need access for assistive devices turned on, which you can do by going in to System Preferences, Universal Access. At the bottom check the box for “Enable access for assistive devices”.
As it is, the script will tell all applications currently running, that if they have a window that is entirely on the main display – to move it to the top left of the screen.
You may have some applications which keep windows off screen on purpose, if you experience any strange behavior with these applications you can exclude them from the applications which get checked by adding their name to the “processesToIgnore” list at the top of the script. There is an example to show how the list should look in the comment right above it. Be sure to use the exact name of the application.
Lastly, if you have more then one display attached when this script is ran it will basically do the same thing, but windows on other screens will not be moved to the main display, only windows outside the range of all current displays.