How can I script nvidia display setting changes?

I have my tv connected to my Windows XP pc's nvidia GeForce 8500 GT.

I am constantly switching between single display and clone display.

Is there a way to script these settings? I would be fine with writing a batch file or a .net program to do it.

When I want to use my tv I right click the nVidia tray icon -> nView Display Settings -> Clone -> TV + Acer Monitor

When I want to switch back to only my moniter, I right click the nVidia tray icon -> nView Display Settings -> Single Display -> Acer Monitor


Solution 1:

Combined with AutoIT, AutoHotkey or a batch script, this PDF-document (Command Line Functions => Using DTCFG-Configuring the Desktop => DTCFG Desktop Configuration Commands) may be of great assistance.

From that I tried to create a simple AutoHotkey-script, but I am not sure if it works, nor if it does what you want.

single = 1
;----- Ctrl-F2, change to whatever you see fit
^F2::
;----- cloning to screen 2
if (single = 1) {
    run rundll32.exe NvCpl.dll`,dtcfg setview 1 clone,,Hide
    single = 0
} else {
;----- back to primary only
     run rundll32.exe NvCpl.dll`,dtcfg setview 1 standard,,Hide
     currentMode = 2
}
return