3

I'm trying to make myself a little script that I can run on the fly that gathers all my open windows onto the main display.

I think a good starting place would be to be able to trigger Gather Windows (as seen in System Preferences-> Displays) by a shell script, AppleScript, or Automator action.

Can anyone either tell me how to do the above, or point me at a utility that will let me bind a key to do gather windows (freeware preferred)?

3 Answers 3

2

Use AppleScript Editor to save the following as script or application:

tell application "System Preferences"
    set current pane to pane id "com.apple.preference.displays"
    tell application "System Events" to tell process "System Preferences" to tell first window to click button "Gather Windows"
    quit
end tell

Make sure you have enabled support for assistive devices in System Preferences » Universal Access.

2
  • I tried your script but I am getting this error: i.imgur.com/i27ch3O.png
    – orschiro
    Commented Oct 22, 2023 at 11:02
  • @orschiro The layout of the Displays pane has been changed a lot in recent releases of MacOS, so the UI automation breaking is not unexpected. I couldn't quickly find where the feature was moved to update this answer, unfortunately. Commented Oct 25, 2023 at 15:02
0

This article includes an AppleScript that gathers all windows.

It's the only programmatic way I know of to mimic the behaviour of the "gather windows" command in System Preferences.

1
  • Doesn't work OMM. It just doesn't move the window onto the main screen... I do have Access for Assistive Devices enabled. Commented Apr 27, 2011 at 0:28
0

Have you looked at the following list to see if any of these do what you want?

What Window Management Options exist for OS X?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .