Quick-switch between Extended Desktop and Surround?

Discussion in 'nVidia Flavor' started by Unknown-One, Mar 2, 2011.

  1. Cokelover58

    Cokelover58 n00bie

    Messages:
    2
    Joined:
    Mar 11, 2016
    Still doesn't work for me. I've tried all the swaps but none of them will make both read as 2 3 1 correctly. I will try swapping cables.
     
  2. Unknown-One

    Unknown-One [H]ardForum Junkie

    Messages:
    8,862
    Joined:
    Mar 5, 2005
    Oh wow, I'm sorry, I thought you were talking about surround config, but your monitors are getting jumbled when switching BACK to extended mode.

    The script lets Windows determine the monitor-order when returning to extended mode... so yeah, you'll have to figure out why it's doing that, or swap plugs around a little bit.

    Funny, usually Windows remembers the original display config and doesn't jumble anything. I wonder what's different about your setup...
     
  3. digitaltree515

    digitaltree515 n00bie

    Messages:
    4
    Joined:
    Oct 1, 2015
    Unknown-One, thank you very much for fixing the link! I have v10 downloaded, but I get the following error when enabling or disabling via the toggler: "Timed out while waiting for the NVIDIA Control Panel. (Code 602)" Despite this, it enables surround mode ok, but when disabling and receiving that error only my left display (display 2, according to my non-OCD friendly Windows 10) activates and I have to manually enable display 1 (the right monitor). Any help would be greatly appreciated!
     
  4. digitaltree515

    digitaltree515 n00bie

    Messages:
    4
    Joined:
    Oct 1, 2015
    I figured out what's causing the control panel timeout error. The control panel surround settings aren't displaying because some applications prevent it from doing so. If you select configure surround it will tell you what programs are doing so, and closing them out corrects this problem. So, it appears it's an issue with nvidia... Now, if I could figure out how to force certain programs to not use the GPU I think this problem could be corrected...
     
  5. Unknown-One

    Unknown-One [H]ardForum Junkie

    Messages:
    8,862
    Joined:
    Mar 5, 2005
    I check the "Span displays with Surround" box, and then immediately click "Apply"

    Clicking "Apply" instead of "Configure" skips the dialog box telling you to close programs, so that's not the problem...

    Edit: Also, what you described would generate a 601 error, as a 602 error can only occur after the "NVIDIA Set Up Surround" window is found, and that window can only be found if the script gets past the window asking you to close programs.
     
    Last edited: Mar 14, 2016
  6. Unknown-One

    Unknown-One [H]ardForum Junkie

    Messages:
    8,862
    Joined:
    Mar 5, 2005
    Walking through the process...
    So all I can figure is, your system consistently takes longer than 16 seconds to change display modes... let me hack something up for you real quick.

    Edit: I made the script loop the routine that checks your display mode for 32 seconds instead of 16, see if it helps on your system: Nvidia Surround Toggle v11_Pre1.exe
     
    Last edited: Mar 14, 2016
  7. digitaltree515

    digitaltree515 n00bie

    Messages:
    4
    Joined:
    Oct 1, 2015

    All I can tell you is that when I close out the programs NVIDIA wants closed, it works flawlessly both ways, but when they remain open I get the 602 error both ways. It still works, but upon disabling surround via the toggler my second monitor does not get reactivated and I have to do it manually (on top of the 602 error).
     
  8. Unknown-One

    Unknown-One [H]ardForum Junkie

    Messages:
    8,862
    Joined:
    Mar 5, 2005
    Yeah, can't replicate that behavior on my end... works flawlessly every time, even when applications are open that Nvidia wants you to close.

    Going to need some more info:
    - Are you still seeing the same issue with v11_Pre1 that I linked above?
    - What Windows version?
    - What Nvidia display driver version?
    - What is the resolution of each monitor?
    - Portrait or landscape?

    Are you sure you're getting a "602" error when switching back to extended mode? Because that's impossible... All error codes involved with switching to extended mode are in the 500 range.
    - Error 501: Took longer than 15 seconds to switch back to Extended mode
    - Error 502: Loop was escaped unexpectedly
     
    Last edited: Mar 16, 2016
  9. Midnight-HOCP

    Midnight-HOCP n00bie

    Messages:
    1
    Joined:
    Mar 29, 2016
    First of all, thanks for writing this useful little tool to do what nVidia obviously isn't capable or willing to do - guess surround users are just too niche to be bothered with...

    Anyway, I'm using a German version of Windows 10 (x64) and when I start v10 (switching from extended to surround mode) the following happens:

    1. A window opens saying "Switching to surround mode..."
    2. Simultaneously the NVIDIA control panel (NVIDIA Systemsteuerung) opens
    3. Several seconds nothing happens
    4. I get the Error code 401 (Timed out while waiting for the NVIDIA Control Panel.)

    I'm guessing this might have something to do with me having the German version of the control panel and AHK looking specifically for the English window titles. If that's true I'd grateful if you could tell me the lines (or the specific strings) that need to be changed in the source code and I'd change and recompile it locally.
    Also, when I tried v11_Pre1 I got a windows warning about possible malicious code, which is curious since it isn't triggered with v10.

    edit: Alternatively - does anyone know how to force the nVidia driver to install the English version of the control panel or change the language afterwards? Changing the region setting within windows didn't have any noticeable effect for me...
     
    Last edited: Mar 29, 2016
  10. PeterFragon

    PeterFragon n00bie

    Messages:
    1
    Joined:
    May 4, 2016
    if I offered time and access to an SLI set up would you be interested in working on adding this support?
     
  11. jedolley

    jedolley [H]ard|Gawd

    Messages:
    1,055
    Joined:
    Feb 28, 2007
    I have been using this for several weeks now and it has been great. However, I recently added an accessory display to the mix and am now having issues. I saw some discussion in regards to another user and an accessory display and wanted to see if this was ever resolved.
     
  12. 4DC957

    4DC957 n00bie

    Messages:
    4
    Joined:
    Sep 17, 2015
    I don't think it's been resolved. I ended up just running the accessory display off my igpu which works flawlessly.
     
  13. Beerbob

    Beerbob n00bie

    Messages:
    18
    Joined:
    Jul 18, 2010

    Hello, Unknown One:

    Thanks for the script, but it's been doing weird things, like when I switch to surround, it swaps left and right monitors. When I switch back to extended, left and middle monitors go black, and the right one becomes the main.

    Do I have to enumerate the monitors in the Windows settings, or the Nvidia settings to make it work properly?

    Like I said, thanks for all this hard work. It seems to be working pretty well for most folk.

    Beerbob
     
  14. hairypaulsack

    hairypaulsack n00bie

    Messages:
    1
    Joined:
    May 26, 2016
    Okay so this is a question for unknown or everybody if someone has the answer.


    Back in the day before this little gem found it's way to the heart of my PC, like many or most all of you, not only did I have to activate and deactivate Surround the stupid crap way NVIDIA gave is, but also had to do an extra step. See the majority of my games are sims as opposed to overhead strategy (just to pick an example where bezel would not only not be needed, but could also be detremental as it would block things off the screen) so that means that when I'm flying in cockpit or driving the track I want the frame of the car and cockpit to line up from monitor to monitor, AKA utilize the bezel feature. I even use it for movies... It does cause you to lose some screen area during menus and game videos, but thanks to NVIDIA we do have the quick activate/deactivate bezel hotkey.



    So here's the question.

    Every time I activated Surround I would follow these steps.

    1. Open Surround Menu.
    2. Before activating surround I would enter in the desired bezel pixel amount for each gap between screens. 100. bezel pic apperas, I am happy. Next step
    3. I would hit apply and the bezel picture would app ensure to you that you have the right bezel selected, but it never would activate itself.


    Even after specifying a bezel amount it would put me at a resolution that excluded the bezel.

    Don't laugh at me, lol but I have 3x 5:4 19'' Monitors with a max resolution of 1280x1024 per monitor which allows a maximum resolution of 3840x1024..... 12:3 = 4:1 = BARFFFFF!!!!!

    So the Surround enabled max display would be set at 3840x1024. Having allocated bezel compensation by specifying my desired 100 pixel per gap only half way gets me to the end result.


    So with this great program unfortunately the bezel is selected and applied, but after iterations of script I still find myself at 3840x1024 and I am forced to go into windows display and change to 4040x1024 (3840 + 2x 100px bezels = 4040) or likewise I can change from nvidia panel.



    Is there a simple script I can add to the end of my v10 NVToggle script and recompile it for a custom version to my own? I'm sure I can figure out the .exe to call windows display properties just like I can automate the process to change the resolution in the drop down menu and OK it for final changes. I guess what I mostly need from you guys (IF THIS IS THE PROPER ROUTE I SHOULD TAKE FOR MY PERSONAL SITUATION) is where in the heck would I add this in the AHK script? I'm still new to AHK and AiT so I can kinda follow the Nvidia Surround Toggle script with breakpoint control or whatever I did to make it go step by step but I still get lost. Where would you guys put it? Create a new functions to precede the exit function? Like have it go to newFunction() then exit? Will this work?


    Thanks
     
  15. the0dan

    the0dan n00bie

    Messages:
    1
    Joined:
    Aug 11, 2006
    Unknown-One, thanks so much for your work on this. I've been waiting for this feature forever.

    v10 works great for me, except one little thing. I have 3 monitors in surround and a 4th connection to my A/V receiver via the HDMI port, which I use for HD audio.

    When using your script to go into Surround mode, it doesn't remember to enable my 4th display (i.e. my A/V receiver). So, after running the script, I have to open Nvidia Control Panel, click on "Set up multiple displays", and manually check the checkbox for my 4th display, then click Apply.

    Is there any way to add that functionality to your script? It's not a major problem, but thought I'd ask. It might be useful for others who use a 4th connection for HD audio.

    Many thanks for all your work so far.

    -the0dan
     
  16. milkan

    milkan n00bie

    Messages:
    1
    Joined:
    Jul 14, 2016
    Man this is such a great program. I was scouring the internet and nowhere could I find any solutions to quickly switch between extended and nvidia surround mode.

    Thanks Unknown One for making such a nice program.

    I am personally using SwapScreen method #4 because my monitors seem to shift to the right during surround mode. Everything is working nicely.

    I did notice something though. Even though the program seems to be able to take in the correct Bezel correction (in my case 85), for some reason only the basic 5760x1080 resolution is selected instead of the bezel corrected one 5930x1080.

    Is there anyway for the script to switch to the bezel corrected resolution automatically?

    Regards
     
  17. Smygolf

    Smygolf n00bie

    Messages:
    2
    Joined:
    Aug 11, 2016
    I can't praise you enough for this Unknown One. Finally upgraded to win 10 from wind 7, where changing between modes was such a hassle. This is sooo much easier, thank you for sharing.

    The only issue now is that I have to manually change to bezel corrected resolution, like milkan above explained.
     
  18. kludger

    kludger n00bie

    Messages:
    4
    Joined:
    Feb 20, 2012
    Just wanted to thank you for this useful utility, really makes life easier despite Nvidia's lack of attention to surround mode niceties.
     
  19. s33d1ing

    s33d1ing n00bie

    Messages:
    3
    Joined:
    Oct 12, 2016
    I created a wrapper program to apply the bezel corrected resolution after Nvidia Surround Toggle has run. Simply put NVSTogglePlus.exe in the same directory as the Nvidia Surround Toggle exe, then run it. It runs the Nvidia Surround Toggle exe then, it adjusts your resolution according to the bezel correction value in C:\ProgramData\NVSToggle\NVSToggle.ini.
     

    Attached Files:

    Last edited: Oct 12, 2016
  20. Smygolf

    Smygolf n00bie

    Messages:
    2
    Joined:
    Aug 11, 2016
    I tried your wrapper exe s33d1ing, but can't get it to work.
    I have it in the same folder as Nvidia Surround Toggle v10.exe. When I start NVSTogglePlus.exe nothing happens.
    Any ideas?
     
  21. s33d1ing

    s33d1ing n00bie

    Messages:
    3
    Joined:
    Oct 12, 2016
    I had the program searching in the directory for the exe in case it was named something else. I hard coded it to look for ".\Nvidia Surround Toggle v10.exe" now. Give this a shot.

    If its still not working, here is a PowerShell script to the do the same thing. GitHub - s33d1ing/NVSTogglePlus
     

    Attached Files:

    Last edited: Oct 15, 2016
  22. Unknown-One

    Unknown-One [H]ardForum Junkie

    Messages:
    8,862
    Joined:
    Mar 5, 2005
    Official release of version 11 http://www.mediafire.com/file/f793os69f2fd2al/Nvidia_Surround_Toggle_v11.zip

    Changelog:
    - Added a "Topology" configuration option. This can be useful if the Nvidia Control Panel doesn't defualt to 1x3 mode.
    - This script ONLY supports 1x3 mode, so make sure the Topology setting you choose corresponds to 1x3 mode in the Nvidia Control Panel!

    INI File (%programdata%\NVSToggle\NVSToggle.ini) definitions:
    Code:
    BezelCorrection=128
        The bezel correction value (in pixels).
        Valid settings for this option are 0 through 1024.
    
    SwapScreens=0
        Re-order screens in Surround mode.
        0 = Nothing swapped
        1 = Swap left and right
        2 = Swap left and center
        3 = Swap right and center
        4 = Wrap left-to-right
        5 = Wrap right-to-left
    
    Orientation=0
        Screen orientation in Surround mode.
        0 = Landscape
        1 = Portrait
        2 = Inverted landscape
        3 = Inverted portrait
    
    Topology=0
        Sets the Surround Topology (You must select the option that corresponds to 1x3 mode!)
        0 = Do not modify the default setting.
        1 = 1st option in the Topology drop-down menu
        2 = 2nd option in the Topology drop-down menu
        3 = 3rd option in the Topology drop-down menu
        4 = 4th option in the Topology drop-down menu
    
    TaskbarFix=0
        Fix for windows maximizing behind the taskbar in Surround mode
        0 = Fix Disabled (Default)
        1 = Fix Enabled
    
    ShowStatusWindow=1
        Status window that displays current operation while the script runs
        0 = Status window disabled
        1 = Status window enabled (Default)
    
    Original post has been updated with the latest version info, as well. :D
     
  23. s33d1ing

    s33d1ing n00bie

    Messages:
    3
    Joined:
    Oct 12, 2016
    NVSTogglePlus has been updated for the latest version of Nvidia Surround Toggle. It now requires you to rename (or copy) Nvidia Surround Toggle v*.exe to NVSToggle.exe and place it in the same directory as NVSTogglePlus.exe.

    I ran into some issues with Nvidia Surround Toggle v11.exe being blocked when I first downloaded it. Make sure NVSToggle.exe and NVSTogglePlus.exe are not blocked by your computer if you have any problems.
     

    Attached Files:

  24. Phoentje

    Phoentje n00bie

    Messages:
    1
    Joined:
    Feb 14, 2017
    Hi I am trying to run this v11 tool on my GTX970 but it fails with CODE 401
    What I see is that it opens the control panel for NVIDIA settings but then loads until the error appears on screen.

    I changed the Topology=2 wich for me is 1x3

    Any hints?
     
  25. k4sh

    k4sh n00bie

    Messages:
    1
    Joined:
    Feb 17, 2017
    Like most of us all i had problems making this script to work as i got the exit code 401 with no response from NVIDIA Control Panel.
    I got that The NVCP had to be in english to have it working.
    So i ended up by editing the ahk script.

    So first of all, you have to launch the NVIDIA Control Panel.
    After that, Open the task manager and Locate the NVIDIA process. Expand it and write down the the NVIDIA window title as shown below.
    This will be string #1
    Task_manager.png

    Then, Locate in the NVIDIA control panel the following window.
    The string red highlighted will be string #2
    Span_disp.png

    Then, Locate in the NVIDIA control panel the following window.
    The string red highlighted will be string #3
    Surround setup.png

    Now, it's time to open the autohotkey script.
    Search and replace in the script the string "NVIDIA Control Panel" with string #1 previously memorised.

    Search and replace in the script the string "Span &displays with Surround" with string #2 previously memorised.

    Search and replace in the script the string "NVIDIA Set Up Surround" with string #3 previously memorised.

    After that, i got the script to work except for one thing. The screens arrangement could not be processed successfully.
    In fact, it would trigger randomly with some random effects until i realised that the screens swapping needed some pause before triggering.
    So, look for the following code into the script and replace the "Sleep 200" command line with a greater value (eg : Sleep 500).
    For me, the sweet spot seems to be at 400.
    Code:
            IF (SwapScreenVar != 0){
                Sleep 200
                IF (SwapScreenVar = 1)                            ; 1 Swap left and right
                    MouseClickDrag, Left, 300, 200, 700, 200, 1
                IF (SwapScreenVar = 2)                            ; 2 Swap left and center
                    MouseClickDrag, Left, 300, 200, 520, 200, 1

    Finally, and because NVIDIA surround setting cannot start with some process in background, i added some commands in my script to kill them.
    It's sad to have this done as AMD can deal with it flawlessly.

    Code:
    ;==============================================================================================
    ; 4 Kill Tasks that may load randomly by itself on Windows 10
    ;==============================================================================================
    RunWait , taskkill /im Video.UI.exe /f, , Hide        ; Movies and TV
    RunWait , taskkill /im Calculator.exe /f, , Hide    ; Calculator
    I've inserted that code before section 4 but it would be wiser to do it in the surround toggle section.

    Here is my final script.
    You may edit it as much as needed.

    Code:
    ;==============================================================================================
    ; 0 Set Defaults
    ;==============================================================================================
    #NoTrayIcon
    #SingleInstance ignore
    #Persistent
    
    INISection1 = NVSToggleInternal
    AppVersionStatic = 11
    CfgVersionStatic = 11
    
    INISection2 = UserOptionsSurround
    BezelCorrectionStatic = 42
    SwapScreensStatic = 0
    OrientationStatic = 0
    TopologyStatic = 0
    TaskbarFixStatic = 0
    
    INISection3 = UserOptionsExtended
    AccessoryDisplayStatic = 0
    
    INISection4 = GlobalOptions
    ShowStatusWindowStatic = 1
    TimingModeStatic = 1
    
    OnExit, ExitSub
    
    ;==============================================================================================
    ; 1 Write new configuration file
    ;==============================================================================================
    IniRead, CfgVersionVar, %programdata%\NVSToggle\NVSToggle.ini, %INISection1%, CfgVersion
        IF CfgVersionVar != %CfgVersionStatic%
        {
            FileRemoveDir, %programdata%\NVSToggle\, 1
            FileRemoveDir, %appdata%\NVSToggle\, 1
            FileCreateDir, %programdata%\NVSToggle
        
            IniWrite, %AppVersionStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection1%, AppVersion
            IniWrite, %CfgVersionStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection1%, CfgVersion
            IniWrite, %BezelCorrectionStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection2%, BezelCorrection
            IniWrite, %SwapScreensStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection2%, SwapScreens
            IniWrite, %OrientationStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection2%, Orientation
            IniWrite, %TopologyStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection2%, Topology
            IniWrite, %TaskbarFixStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection2%, TaskbarFix
            IniWrite, %AccessoryDisplayStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection3%, AccessoryDisplay
            IniWrite, %ShowStatusWindowStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection4%, ShowStatusWindow
            IniWrite, %TimingModeStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection4%, TimingMode
        
            MsgNewCFG()
        }
    
    ;==============================================================================================
    ; 2 Read and validate configuration file
    ;==============================================================================================
    IniRead, AppVersionVar, %programdata%\NVSToggle\NVSToggle.ini, %INISection1%, AppVersion
        IF (AppVersionVar < AppVersionStatic)
            IniWrite, %AppVersionStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection1%, AppVersion
    
    IniRead, BezelCorrectionVar, %programdata%\NVSToggle\NVSToggle.ini, %INISection2%, BezelCorrection
        IF (BezelCorrectionVar < 0) or (BezelCorrectionVar > 1024){
            IniWrite, %BezelCorrectionStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection2%, BezelCorrection
            BezelCorrectionVar = %BezelCorrectionStatic%
        }
    IniRead, SwapScreenVar, %programdata%\NVSToggle\NVSToggle.ini, %INISection2%, SwapScreens
        IF (SwapScreenVar < 0) or (SwapScreenVar > 5){
            IniWrite, %SwapScreensStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection2%, SwapScreens
            SwapScreenVar = %SwapScreensStatic%
        }
    IniRead, OrientationVar, %programdata%\NVSToggle\NVSToggle.ini, %INISection2%, Orientation
        IF (OrientationVar < 0) or (OrientationVar > 3){
            IniWrite, %OrientationStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection2%, Orientation
            OrientationVar = %OrientationStatic%
        }
    IniRead, TopologyVar, %programdata%\NVSToggle\NVSToggle.ini, %INISection2%, Topology
        IF (TopologyVar < 0) or (TopologyVar > 4){
            IniWrite, %TopologyStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection2%, Topology
            TopologyVar = %TopologyStatic%
        }
    IniRead, TaskbarFixVar, %programdata%\NVSToggle\NVSToggle.ini, %INISection2%, TaskbarFix
        IF (TaskbarFixVar < 0) or (TaskbarFixVar > 1){
            IniWrite, %TaskbarFixStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection2%, TaskbarFix
            TaskbarFixVar = %TaskbarFixStatic%
        }
    IniRead, AccessoryDisplayVar, %programdata%\NVSToggle\NVSToggle.ini, %INISection3%, AccessoryDisplay
        IF (AccessoryDisplayVar < 0) or (AccessoryDisplayVar > 1){
            IniWrite, %AccessoryDisplayStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection3%, AccessoryDisplay
            AccessoryDisplayVar = %AccessoryDisplayStatic%
        }
    IniRead, ShowStatusWindowVar, %programdata%\NVSToggle\NVSToggle.ini, %INISection4%, ShowStatusWindow
        IF (ShowStatusWindowVar < 0) or (ShowStatusWIndowVar > 1){
            IniWrite, %ShowStatusWindowStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection4%, ShowStatusWindow
            ShowStatusWindowVar = %ShowStatusWindowStatic%
        }
    IniRead, TimingModeVar, %programdata%\NVSToggle\NVSToggle.ini, %INISection4%, TimingMode
        IF (TimingModeVar < 1) or (TimingModeVar > 3){
            IniWrite, %TimingModeStatic%, %programdata%\NVSToggle\NVSToggle.ini, %INISection4%, TimingMode
            TimingModeVar = %TimingModeStatic%
        }
     
    ;==============================================================================================
    ; 2a Configure Execution Timings
    ;==============================================================================================
    ;Default timings                                                ; Default timings applied unconditionally to ensure timings are never null
        Sleep1 = 0
        Sleep2 = 500
        Sleep3 = 1000
    
    IfEqual TimingModeVar, 2                                        ; Adjusted timings for slow computers
    {
        Sleep1 = 100
        Sleep2 = 1000
        Sleep3 = 1500
    }
    
    IfEqual TimingModeVar, 3                                        ; Adjusted timings for very slow computers
    {
        Sleep1 = 1500
        Sleep2 = 1500
        Sleep3 = 3000
    }
    
    ;==============================================================================================
    ; 3 Determine current display state
    ;==============================================================================================
    IF (OrientationVar = 1) or (OrientationVar = 3)
        AspectRatioVar = 0.8
    Else
        AspectRatioVar = 3.6
    
    IF (AspectRatioVar < A_ScreenWidth/A_ScreenHeight)
    {
        ToggleVar = ToggleOff
        IfEqual, ShowStatusWindowVar, 1
            MsgSplash("Switching to extended mode...")
    }
    
    IF (AspectRatioVar >= A_ScreenWidth/A_ScreenHeight)
    {
        ToggleVar = ToggleOn
        IfEqual, ShowStatusWindowVar, 1
            MsgSplash("Switching to surround mode...")
    }
    
    ;==============================================================================================
    ; 4 Kill Tasks that may load randomly by itself on Windows 10
    ;==============================================================================================
    RunWait , taskkill /im Video.UI.exe /f, , Hide        ; Movies and TV
    RunWait , taskkill /im Calculator.exe /f, , Hide    ; Calculator
    
    ;==============================================================================================
    ; 5 Open NVIDIA Control Panel hidden
    ;==============================================================================================
    Runwait, taskkill /im nvcplui.exe /f, , Hide                        ; Make sure the NVCPL isn't  already open before proceeding
    SetTimer, NVWindowOpacity, 2                                ; Make sure NVCPL window is hidden as quickly as possible
    
    Loop{
        Run "C:\Program Files\NVIDIA Corporation\Control Panel Client\nvcplui.exe"
        WinWait, Panneau de configuration NVIDIA, , 15
            IF ErrorLevel
                Msg("Time", "401")
        
            SetTimer, NVWindowOpacity, Off
            CenterWindow(Panneau de configuration NVIDIA)
            WinActivate
    
        Loop{
            IfWinExist, , Configurer Surround et PhysX
            {
                Sleep, %Sleep3%
                ControlClick, Button4                            ; Span displays with surround checkbox
                Sleep, %Sleep2%
                ControlClick, Button7                            ; Apply button
                Goto, %ToggleVar%
            }
    
            IfWinExist, , Set PhysX Configuration                    ; The presence of this menu item indicates Surround is not supported
                Msg("Compat", "402")
    
            Sleep 100
            IF a_index > 20                                    ; Assume control panel has loaded and the page needs to be switched
            {
                ControlClick, Static3                                ; Configure Surround link
                Sleep 1000
                Runwait, taskkill /im nvcplui.exe /f, , Hide
                Sleep 500
                Break
            }
        }
     
        IF a_index > 3
            Msg("Time", "403")
    }
    
    Msg("Error", "404")
    
    ;==============================================================================================
    ; 6 Toggle-off (switch to Extended Desktop mode)
    ;==============================================================================================
    ToggleOff:
        Loop{
            IF (AspectRatioVar > A_ScreenWidth/A_ScreenHeight){
                Sleep 200
                Runwait %windir%\System32\DisplaySwitch.exe /extend
            
                IF (AccessoryDisplayVar = 1){                        ; Quick user-specific hack to swap around displays in Extended mode
                    Sleep 1000
                    WinActivate, Panneau de configuration NVIDIA                ; Reactivate window
                    Sleep 200
                    ControlClick, Static10                        ; Set up multiple displays link
                    Sleep 2000
                    WinMove, , , 0, 0, 1024, 768                    ; Move window on-screen and set specific size
                    Sleep 200
                    MouseClick, Left, 339, 320, 1, 1                ; Uncheck 4th Monitor
                    Sleep 1000
                    MouseClickDrag, Left, 426, 520, 621, 520, 1        ; Swap positions of left and center screens
                    Sleep 1000
                    WinMove, -4096, -4096
                    Sleep 200
                    ControlClick, Button2                        ; Apply Button
                    Sleep 2000
                    Runwait, taskkill /im nvcplui.exe /f, , Hide
                    ExitApp
                }
                Sleep 500
                Runwait, taskkill /im nvcplui.exe /f, , Hide
                ExitApp
            }
        
            Sleep 100
            IF a_index > 150
                Msg("Time", "501")
        }
    
    Msg("Error", "502")
     
    ;==============================================================================================
    ; 7 Toggle-on (switch to Surround mode)
    ;==============================================================================================
    ToggleOn:
        SetTimer, NVWindowOpacity, 2                            ; Make sure NVCPL window is hidden as quickly as possible
        WinWait, Configuration du Surround NVIDIA, , 15
            IF ErrorLevel
                Msg("Time", "601")
        
            SetTimer, NVWindowOpacity, Off
            WinMove, 0, 0
            WinActivate
     
            Sleep, %Sleep1%                                    ; TIMING MODE 2+ Wait for the window to become ready
    
            IF (TopologyVar != 0){
                IF (TopologyVar = 1){
                    ControlClick, ComboBox1
                    Send {PgUp}{enter}
                }
                IF (TopologyVar = 2){
                    ControlClick, ComboBox1
                    Send {PgUp}{Down}{enter}
                }
                IF (TopologyVar = 3){
                    ControlClick, ComboBox1
                    Send {PgDn}{Up}{enter}
                }
                IF (TopologyVar = 4){
                    ControlClick, ComboBox1
                    Send {PgDn}{enter}
                }
            }
        
            IF (SwapScreenVar != 0){
                Sleep 400
                IF (SwapScreenVar = 1)                            ; 1 Swap left and right
                    MouseClickDrag, Left, 300, 200, 700, 200, 1
                IF (SwapScreenVar = 2)                            ; 2 Swap left and center
                    MouseClickDrag, Left, 300, 200, 520, 200, 1
                IF (SwapScreenVar = 3)                            ; 3 Swap right and center
                    MouseClickDrag, Left, 550, 200, 330, 200, 1
                IF (SwapScreenVar = 4){                            ; 4 Wrap right to left
                    MouseClickDrag, Left, 640, 200, 420, 200, 1
                    Sleep 200
                    MouseClickDrag, Left, 420, 200, 200, 200, 1
                    }
                IF (SwapScreenVar = 5){                            ; 5 Wrap left to right
                    MouseClickDrag, Left, 200, 200, 420, 200, 1
                    Sleep 200
                    MouseClickDrag, Left, 420, 200, 640, 200, 1
                    }
                }
            
            IF (OrientationVar != 0){
                Sleep 200
                IF (OrientationVar = 1){
                    MouseClick, Right, 330, 145, 1, 1
                    MouseClick, Left, 343, 180, 1, 1
                    }
                IF (OrientationVar = 2){
                    MouseClick, Right, 330, 145, 1, 1
                    MouseClick, Left, 343, 203, 1, 1
                    }
                IF (OrientationVar = 3){
                    MouseClick, Right, 330, 145, 1, 1
                    MouseClick, Left, 343, 224, 1, 1
                    }
            }
        
            Sleep 200
            ControlClick, Edit1                                    ; Bezel Correction Value
            Sleep, %Sleep1%                                    ; TIMING MODE 2+ Wait for the window to become ready
            Send %BezelCorrectionVar%{Delete}{enter}
    
        Loop{
            IF (AspectRatioVar < A_ScreenWidth/A_ScreenHeight)
            {
                IfEqual, TaskbarFixVar, 1
                {
                    WinClose, Configuration du Surround NVIDIA
                    MsgSplash("Applying window maximization fix...")    ; Update splash window
                    WinWaitClose
                    
                    WinActivate, Panneau de configuration NVIDIA
                    Sleep 500
                    Loop, 2                                    ; Fix for windows maximizing behind the taskbar
                    {
                        Sleep 200
                        Send {Alt}
                        Sleep 100
                        Send k
                        Sleep 100
                        Send s
                        Sleep 100
                        Send c
                    }
                }
                Sleep 200
                Runwait, taskkill /im nvcplui.exe /f, , Hide
                ExitApp
            }
        
            Sleep, 100
            IF a_index > 320
                Msg("Time", "602")
        }
    
    Msg("Error", "603")
    
    ;==============================================================================================
    ; 8 Functions
    ;==============================================================================================
    MsgNewCFG(){
        MsgBox, 323, Nvidia Surround Toggle, A new config file has been created in the following location:`n"%programdata%\NVSToggle\NVSToggle.ini"`n`nWould you like to edit these settings now?
            IfMsgBox Cancel
                ExitApp
            IfMsgBox Yes
                RunWait %windir%\System32\Notepad.exe %programdata%\NVSToggle\NVSToggle.ini
        Return
    }
    
    Msg(MsgString, ErrCode){
        Run, taskkill /im nvcplui.exe /f, , Hide
        SplashTextOff
        IfEqual, MsgString, Compat
            MsgBox, 64, Nvidia Surround Toggle, Attention: `nYour system is not NVIDIA Surround capable.
        IfEqual, MsgString, Error
            MsgBox, 16, Nvidia Surround Toggle, Error: `nExecution halted unexpectedly. (Code %ErrCode%)
        IfEqual, MsgString, Time
        {
            MsgBox, 16, Nvidia Surround Toggle, Error: `nTimed out while waiting for the NVIDIA Control Panel. (Code %ErrCode%)
            IfEqual, TimingModeVar, 1
                IniWrite, 2, %programdata%\NVSToggle\NVSToggle.ini, %INISection4%, TimingMode
            IfEqual, TimingModeVar, 2
                IniWrite, 3, %programdata%\NVSToggle\NVSToggle.ini, %INISection4%, TimingMode
        }
        ExitApp
    }
    
    MsgSplash(SimpleText){
        SplashTextOn, 320, 68, NVIDIA Surround Toggle, `n%SimpleText%
        WinSet, AlwaysOnTop, On, NVIDIA Surround Toggle
    }
    
    CenterWindow(WinTitle){
        WinGetPos,,, Width, Height, %WinTitle%
        WinMove, %WinTitle%,, (A_ScreenWidth/2)-(Width/2), (A_ScreenHeight/2)-(Height/2)
    }
    
    ;==============================================================================================
    ; 9 Async Timers
    ;==============================================================================================
    NVWindowOpacity:
        WinSet, Transparent, 1, Panneau de configuration NVIDIA
        WinSet, Transparent, 1, Configuration du Surround NVIDIA
    Return
    
    ExitSub:
        Sleep 600
        RunWait, C:\Program Files (x86)\Desktop Ok\DesktopOK_x64.exe /load /silent c:\Position_centree.dok, , Hide
        Run, taskkill /im nvcplui.exe /f, , Hide
        SplashTextOff
        ExitApp
    Return
    
    ;==============================================================================================
    ; 10 Hotkeys
    ;==============================================================================================
    Esc::Msg("Error", "901")
    I have to mention that all my tests have been done with Windows 10.
    I have no idea if the process should be the same with a prior version.
    Credits goes to unknown for his hard work to make it possible.
     
    Last edited: Feb 17, 2017
  26. NilDotZer0

    NilDotZer0 n00bie

    Messages:
    3
    Joined:
    May 22, 2015
    Unfortunately this great script is no longer working with the Win 10 Creators Update installed.

    Switching from extended to surround still works like charm, but going back to extended produces an error stating it can't find DisplaySwitch.exe in System32, which (of course) is nonsense.
    File is there, and launching it manually works fine.
    I've pinned this down to definitely being a creators update problem by restoring backups several times and eliminating any other possible difference, to me it seems there's a problem between AutoHotkey itself and the latest WIn10 build.

    Unfortunately I'm not that familiar with AutoHotkey or AutoIT, so I rely on some of you other nerds to look into this.

    Since NVidia still hasn't implemented proper profile management it'd be a pity to loose the convenience gained by this script.
     
  27. xikkub

    xikkub n00bie

    Messages:
    1
    Joined:
    May 3, 2017
    Just as a heads up to whom this may concern: If you've noticed the error "Failed attempt to launch program or document:" with "Action: <C:\WINDOWS\System32\DisplaySwitch.exe>", you can try installing AutoHotkey yourself and running the .ahk script instead of the pre-bundled .exe (The .ahk script can be found in the "Source" directory of OP's zip file). If you really need the exe version, you can use AutoHotkey to compile the ahk to exe by right-clicking the .ahk file and then clicking "Compile Script" (or manually using ahk2exe).

    A friend noticed this problem after installing the Windows 10 Anniversary Update, but installing AutoHotkey and recompiling the script solved it. Be sure to install the appropriate AutoHotkey version given your system architecture (32-bit / 64-bit).

    If your problem is not specifically related to the one I described, you may still want to install AutoHotkey yourself and try the above solution. The version of AutoHotkey bundled with the OP's exe file seems to cause problems on my friend's system (Windows 10 Pro, Version 1703, OS Build 15063.138). If you somehow installed your NVIDIA tools/drivers to a drive with a different letter (other than C, then you will need to update all of the file paths in the ahk script to reflect this.

    It's also ill-advised to run random exe files from the internet (!!!), though the OP's version (at the time of posting this) appears to be legitimate when decompiled. Don't take my word for it, though. Details below anyway.

    Nvidia Surround Toggle v11.zip
    SHA256: e164149b9d02b1cbba2a4a2f784935602577fa97dbd5e751a1058edd31500c02
    MD5: dcbc96da1b8652ff030a4b47b2737b4b
     
  28. Capu

    Capu n00bie

    Messages:
    1
    Joined:
    May 23, 2017
    Hey I followed your tutorial but I have now the erreor "Timed out while waiting for the NVIDIA Control Panel. (Code 602).

    Do you have an idea what the problem is? I can't find anything :/

    Thanks a lot!
     
    Last edited: May 26, 2017
  29. veedubfreak

    veedubfreak 2[H]4U

    Messages:
    2,074
    Joined:
    Dec 10, 2007
    Oh hay neat this thread is still alive. Finally went back to single card.
     
  30. Unknown-One

    Unknown-One [H]ardForum Junkie

    Messages:
    8,862
    Joined:
    Mar 5, 2005
    I finally have time to work on this again! Hoping to implement the following features soon:
    • Pre-Compiled with the latest 64-bit version of Autohotkey (Done!).
    • Support for non-English systems.
    • Fix for timeout issues on some systems (Where Surround configuration defaults to all displays unchecked).
    I should be able to release something by tomorrow night.

    Also, in spite of having no personal interest in SLI, I'm on the lookout for a cheap 980Ti so I can finally work-out a scripted solution for SLI systems. If anyone sees a 980Ti going for super-super cheap, let me know!
     
    Last edited: Jun 30, 2017
  31. dlh007

    dlh007 n00bie

    Messages:
    1
    Joined:
    Nov 10, 2015
    Hello Unknown-One ,

    is this project still alive?
    I use yor script slightly modified for a long time now and will say THANK YOU for this great script.

    I searched for hours then until i found your script, it dont work on german system so i modified it.
    I have get it to work, bot not perfect. Sometimes it works, sometimes not.

    I have a german system, but have "set" my nvidia drivers to english and translate some windows names to german, then it works mostly.

    It would be great if you can add full german support, I'll be glad to help you.

    I hope to read from you.

    Best regards
    DLH007

    EDIT:

    With the help of the post from k4sh, i managed it myself. thank you k4sh :).

    Here is the Download for german user:
     

    Attached Files:

    Last edited: May 16, 2018