Four Steps To Write An AppleScript to Gather ALL Windows on OSX
I have no idea why, but there is no built-in way to gather ALL your desktop windows (from all applications) onto your main display window. There are some apps out there that will do it for each individual application but nothing that I've been able to find that will do it for all windows from all applications at once.
And it doesn't look like I'm alone in wanting something like this. See all these threads out there...
- "Gather windows" for all apps? - Apple Community
- macOS: Bring Off-Screen Window Back Onto Screen - Technipages
- how to rescue windows from off the screen?
Anyway, lets build a simple AppleScript that loops through all your open applications and moves all their (non-minimized) windows to a specific x,y position on your screen and (optionally) resize them.
Step #1 - Fire up the OSX Script Editor
OSX comes with its own built in AppleScript editor called "Script Editor". You can find it under Applications > Utilities.
Step #2 - Paste in the following AppleScript
The AppleScript below with loop through each non-minimized window of every applicaition you have open and and move it's window position to 200, 100 (top left of your screen). It will also resize each window to 1000px by 800px.
If you don't want it to resize your windows or you'd like your windows placed somewhere else you can edit the script accordingly...
use application "System Events"
get the name of every application process whose class of windows contains window
repeat with P in the result
get (every window of process (contents of P) whose value of attribute "AXMinimized" is false)
repeat with W in the result
set position of W to {200, 100}
set size of W to {1000, 800}
end repeat
end repeat
Step #3 - Run the AppleScript
Click the play button in the top left corner to fire off the script...
And after a couple seconds you will hopefully see all your open windows from all your open displays moving up to the top left corner of your screen.
Note: You might be prompted to enable your script with permissions to move windows around. This is called "assistive" permissions, and you can find them inside your Security and Privacy settings in the control panel...
Step #4 - Save Your Script as an Application
Its all well and good to have a script in the script editor that does the window gathering you want, it's better to have that all bundled up as an application so you can run it whenever you want.
To do this, go back to your script editor and under the File dropdown menu hit "Export"...
Then choose to export it as an application...
Now you have an .app file that you can drag onto your doc and run whenever you want to move your windows around in batch.
Hopefully this has been helpful for you. If you've tried out the code here, drop me a tweet at twitter.com/mattccrampton and let me know.
To: @mattccrampton
0
Other Posts
When exporting photos from a service like Flickr, perhaps after they've given notice that they're going to delete our photos if you don't subscribe to......
All Truthy and Falsy Javascript Values In Nodejs, every value has an associated boolean, true or false, value. For example, a null value has an......
Google Forcing Nest Cameras Visual Indicator Light To Be On Received the following email from Google today... Full email text... Recently, we shared our commitment......
Posting to Twitter with Python - Part Two: Posting Photos NOTE: This is part two of my posting to Twitter with Python tutorial. If you......
Doubleclick to open a file in VIM from OSX I use VIM for just about everything from note taking to coding to keeping track of......
Sign Into Gmail Without Signing Into Google Chrome Unfortunately, Google has made changes to Chrome since this blog post was posted which removed the options......