![Four Steps To Write An OSX AppleScript to Gather ALL Windows](/images/blogHeaderImages/2018-08-03-applescript_to_gather_all_windows_on_osx.png)
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.
![Example of gathering all windows](/images/blogImages/2018-08-03-applescript_to_gather_all_windows_on_osx/example.png)
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.
![Open OSX Script Editor](/images/blogImages/2018-08-03-applescript_to_gather_all_windows_on_osx/open_script_editor.png)
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...
![Pasted AppleScript Code](/images/blogImages/2018-08-03-applescript_to_gather_all_windows_on_osx/pasted_code.png)
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...
![Assistive Permissions](/images/blogImages/2018-08-03-applescript_to_gather_all_windows_on_osx/assistive_permissions.jpg)
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"...
![Export your applescript](/images/blogImages/2018-08-03-applescript_to_gather_all_windows_on_osx/export1.png)
Then choose to export it as an application...
![Export your applescript as an application](/images/blogImages/2018-08-03-applescript_to_gather_all_windows_on_osx/export2.png)
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
![Updating File Create Date From Exif Data](/images/blogHeaderImages/2022-03-28-updating-file-create-date-from-exif-data.png)
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](/images/blogHeaderImages/2020-04-28_all_truthy_and_falsy_javascript_values.png)
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](/images/blogHeaderImages/2019-08-14-Google_forcing_nest_cameras_visual_indicator_light_to_be_on.png)
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](/images/blogHeaderImages/2019-07-06-step_by_step_tutorial_to_post_to_twitter_using_python_part_two-posting_with_photos.png)
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](/images/blogHeaderImages/2019-02-19-doubleclick_to_open_in_vim_on_osx.png)
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](/images/blogHeaderImages/2018-09-26-sign-into-gmail-without-signing-into-google-chrome.png)
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......
Other Software Development Blog Posts
![Updating File Create Date From Exif Data](/images/blogHeaderImages/2022-03-28-updating-file-create-date-from-exif-data.png)
![All Truthy and Falsy Javascript Values](/images/blogHeaderImages/2020-04-28_all_truthy_and_falsy_javascript_values.png)
![Google Forcing Nest Cameras Visual Indicator Light To Be On](/images/blogHeaderImages/2019-08-14-Google_forcing_nest_cameras_visual_indicator_light_to_be_on.png)
![Posting to Twitter with Python - Part Two - Posting Photos](/images/blogHeaderImages/2019-07-06-step_by_step_tutorial_to_post_to_twitter_using_python_part_two-posting_with_photos.png)
![Doubleclick to open a file in VIM from OSX](/images/blogHeaderImages/2019-02-19-doubleclick_to_open_in_vim_on_osx.png)
![Sign Into Gmail Without Signing Into Google Chrome](/images/blogHeaderImages/2018-09-26-sign-into-gmail-without-signing-into-google-chrome.png)
![Four Steps To Write An OSX AppleScript to Gather ALL Windows](/images/blogHeaderImages/2018-08-03-applescript_to_gather_all_windows_on_osx.png)
![Four Simple Steps To Post To Twitter Using Python](/images/blogHeaderImages/2017-11-03-step_by_step_tutorial_to_post_to_twitter_using_python.jpg)
![The Mega List Of Free Image Sites For Blogging](/images/blogHeaderImages/2017-11-01-mega_list_of_free_image_sites_for_blogging.jpg)
![A VIM User's Experiments With GUI Code Editors](/images/blogHeaderImages/2017-10-30-a_vim_users_experiments_with_gui_code_editors.png)
![All Python Assert Methods In One List](/images/blogHeaderImages/2017-08-04-a_list_of_all_python_assert_methods.png)
![Invalidate All Cloudfront Files](/images/blogHeaderImages/invalidating_all_files_from_a_cloudfront_distribution_cache_from_the_command_line.png)
![Query an NTP server from Python](/images/blogHeaderImages/88291892461.png)
![Mac Terminal WiFi Commands](/images/blogHeaderImages/64144666914.png)
![Running a for-loop over a Jinja2 dictionary](/images/blogHeaderImages/2012-09-09-iterating_over_a_dict_in_a_jinja_template.png)
Other Blog Posts
![209 Netfix Categories You Dont Know About](/images/blogHeaderImages/2018-09-12-209-netflix-categories-you-dont-know-about.png)
![Easy Recipe For Making Chili at Home with Matt Crampton](/images/blogHeaderImages/2017-11-09-how_to_make_easy_chili.png)
Media Appearances
![Wall Street Journal Live Interview with Matt Crampton](/images/blogHeaderImages/2017-10-26-wsj_live_interview.png)
![NBC Press Here interview with Matt Crampton](/images/blogHeaderImages/2017-10-26-nbc_press_here.png)
![Mobile Monday Silicon Valley panel with Matt Crampton](/images/blogHeaderImages/2017-10-26-mobile_monday_panel.png)
![Human Cloud panel with Matt Crampton](/images/blogHeaderImages/2017-10-26-human_cloud_panel.png)
![Fox Business Interview with Matt Crampton](/images/blogHeaderImages/2017-10-26-fox_business_interview.png)
![Fox Business interview on furloughed government workers with Matt Crampton](/images/blogHeaderImages/2017-10-26-fox_business_furloughed_workers_interview.png)
![Fortune Magazine Live Interview with Matt Crampton](/images/blogHeaderImages/2017-10-26-fortune_magazine_interview.png)
![CCTV Interview with Matt Crampton](/images/blogHeaderImages/2017-10-26-cctv_interview.png)
![8th and Walton show interview with Matt Crampton](/images/blogHeaderImages/2017-10-26-8th_walton_interview.png)
Print Interviews
![MLive Interview with Matt Crampton](/images/blogHeaderImages/2019-04-25-mlive_interview.png)
![Techcrunch Interview on Gigwalk with Matt Crampton](/images/blogHeaderImages/2017-10-26-techcrunch_interview.png)
![Salon.com Labormetrics Interview with Matt Crampton](/images/blogHeaderImages/2017-10-26-salon_labormetrics_interview.png)
![Huffington Post Interview with Matt Crampton](/images/blogHeaderImages/2017-10-26-huffington_going_against_the_flow.png)
![CBS Pulse Interview with Matt Crampton](/images/blogHeaderImages/2017-10-26-cbs_pulse_article.png)
![Silicon Valley Business Journal - Best CIO - Matt Crampton](/images/blogHeaderImages/2014-06-20-silicon_valley_business_journal_best_cio_matt_crampton.png)