Force Mac to detect displays?
Just press the option key while you're in Displays
in System Preferences
. You'll get a Detect displays
button (bottom right).
This is really old but I found a solution that still works in OS X 10.11.2:
hit cmd + "brightness up"
for display detection and cmd + "brightness down"
to switch between mirror and extend display modes. It seems to be the brightness keys and not necessarily the F1 and F2 key.
Here is an AppleScript someone wrote for 10.4 which may help you:
http://www.insanelymac.com/forum/index.php?s=&showtopic=59163&view=findpost&p=457644