I got sick of manually enabling and disabling my external monitor every time I docked the laptop, so I whipped up a quick Autohotkey script to automate it. Autohotkey is an excellent free open source (GPL) utility for creating hotkeys and macros.
You can download the script here. Note that this is tuned for my setup (1024×768 native LCD resolution) and you might have to tweak to get it to work for you.
To use it, makes sure you have Autohotkey installed, download the above script, and double click on it. To use a single monitor hold down the Windows key as you press 1. For two monitors use Windows + 2.
If you want to tweak it for your own system, run AutoScriptWriter (Start->All Programs->AutoHotkey->AutoScriptWriter) and hit record. Now right click on the top right corner of your screen (assuming that’s an empty spot). Press “r”. Press CTRL+SHIFT+Tab. Right click on the second monitor icon thing (where the number 2 is greyed out), and select “attached”. Press enter.
Stop recording the macro (hit Stop on AutoScriptWriter). Save the results. Repeat, this time disabling the external monitor as you record. Use the script below as the cheat sheet.
#2::
Send,{LWINDOWN}m{LWINUP}
MouseClick, right, 1023, 0
Sleep, 100
Send, r
WinWait, Display Properties,
IfWinNotActive, Display Properties, , WinActivate, Display Properties,
WinWaitActive, Display Properties,
Send, {SHIFTDOWN}{CTRLDOWN}{TAB}{SHIFTUP}{CTRLUP}
MouseClick, right, 262, 153
Sleep, 100
MouseClick, left, 275, 158
Sleep, 100
Send, {ENTER}
return
#1::
Send,{LWINDOWN}m{LWINUP}
MouseClick, right, 1023, 0
Sleep, 100
Send, r
WinWait, Display Properties,
IfWinNotActive, Display Properties, , WinActivate, Display Properties,
WinWaitActive, Display Properties,
Send, {SHIFTDOWN}{CTRLDOWN}{TAB}{SHIFTUP}{CTRLUP}
MouseClick, right, 238, 141
Sleep, 100
MouseClick, left, 259, 146
Sleep, 100
Send, {ENTER}
return