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 Answers3

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.

Daniel Beck
  • 2,027
  • I tried your script but I am getting this error: https://i.imgur.com/i27ch3O.png โ€“ orschiro Oct 22 '23 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. โ€“ Daniel Beck Oct 25 '23 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.

robzolkos
  • 10,716
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?