Trigger 'Gather Windows' programmatically (or other quick way) 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)?
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.