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