with Autohotkey, you can emulate the mouse-clicks that toggles the 2nd display.. i don't have a 2nd monitor to test this but if you can provide the keystrokes/mouse-clicks involved then i may be able to make a script with it.. e.g. the following code will partially help you by opening the display properties & click on "advanced settings"..
Run, RunDLL32.EXE shell32.dll`,Control_RunDLL desk.cpl`,`,3 ; Show the Settings tab in Display Properties
WinWait, Display Properties
ControlClick, Ad&vanced, Display Properties ; Open Advanced Properties
Return