1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Quick way to toggle surround/extended

Discussion in 'Videocards - NVIDIA GeForce Drivers Section' started by mstcobra, Jul 22, 2016.

  1. mstcobra

    mstcobra Member Guru

    Messages:
    126
    Likes Received:
    3
    GPU:
    GTX 1080 Ti (H2O)
    Hi everyone,

    I just swapped out my two R9 390s for a GTX 1080. So far I am happy with the card but there doesn't seem to be any way set game profiles to switch the environment from extended desktop to surround, when said specified games are launched. In fact there doesn't seem to be any way that is very quick or efficient.

    Currently I run in extended mode and when I wish to switch to surround I do CTRL + ALT + S and then when I am done I do CTRL + ALT + S followed by Win + P and click Extended to revert back to extended. I wouldn't mind leaving surround enabled at all times but some of my games do not support an ultra wide format and I am not wild about the way the taskbar has to be spanned across all 3 monitors. I did see the option to confine the taskbar to 1 monitor but a side effect of that with Windows 10 at least, seems to be that the start menu still opens on the far left regardless of the taskbar being in the center.

    I have done some research and found some people have luck with associating surround with "Second Screen Only" and simply using Windows + P to select either second screen only or extended to toggle but this is not working for me. From what I can see these posts with that work around are older and it might no longer work with the newer drivers on Windows 10. I have also found a post regarding "Nvidia Surround Toggle" but that doesn't seem to work for me either, it just hangs for a minute or so then crashes.

    So as a total noob to team green; I come to you, Guru of 3D members who I consider the most up to date on anything and everything graphics related for help with a work around/script/solution. Any ideas?
     
  2. mstcobra

    mstcobra Member Guru

    Messages:
    126
    Likes Received:
    3
    GPU:
    GTX 1080 Ti (H2O)
    Ok, so I found a solution. The compiled code available HERE did not work but the code HERE on post 49 worked perfectly. The only thing I wasn't wild about and this was just a personal preference was that it was the same exe to toggle depending on the current state. I wanted two separate exes, one to enable and do nothing if surround was already enabled and another to disable and do nothing if surround was already disabled.

    So in short, if anyone has a similar problem and would like to use the same solution:
    1. Enable your Surround group in the Nvidia control panel as you normally would.
    2. Ensure that you configure hotkeys CTRL+ALT+S to Enable/Disable your Surround group within the Nvidia control panel.
    3. Using AHK compile the scripts below into EXEs.
    4. Save the EXEs somewhere and create shurtcuts in a handy place. I put my shortcuts in the start menu and in a Utilities group at the top of my Steam library. You can also put them in the taskbar of course.
    5. As a finishing touch you can use something like resource hacker to change the exe's icon to an Nvidia one or something of the sort.

    Enable Surround source code

    Disable Surround source code

    Toggle Surround source code

    Anyway, full credit for this awesome script goes to Unknown-One from the [H]ardForum. I just slightly modified it for my own personal preference and figured I would share the experience here.
     
  3. SaiBork

    SaiBork Member Guru

    Messages:
    184
    Likes Received:
    0
    GPU:
    MSI GTX 980Ti Gaming 6G
    Thanks for this, I made some changes as there are some mistakes in the codes posted. Please see the code below.

    This however does not solve the problem I have with surround in Windows 10 as you mentioned yourself already. Even if you set the taskbar to be on the middle screen only, it opens the start menu on the left screen.

    Why can't they just make the taskbar behave as if the screens are in extended mode. This is one of the reasons I barely ever use surround mode anymore. It just has too many issues.

    But sadly Surround is not popular enough for Nvidia to really do much in regards to improving it. And now VR is out I think they will put even less focus into surround.

    Enabling surround:
    Code:
    #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
    #Warn  ; Enable warnings to assist with detecting common errors.
    SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
    SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
    
    ;==============================================================================================
    ; First-run configuration
    ;==============================================================================================
    IniRead, FirstRunVar, %A_AppData%\NVSToggle\NVSToggle.ini, NVSToggle, FirstRun
    IF (FirstRunVar = "Completed")
    {
    Goto, DetectNow
    }
    
    MsgBox, 65, Nvidia Surround Toggle, To allow this application to configure itself for first-time use, please enable Nvidia Surround using the Nvidia Control Panel now. `n`nClick "OK" when ready, or "Cancel" to quit.
    IfMsgBox Ok
    Goto, DoubleCheck
    else
    Exit
    
    DoubleCheck:
    IF (A_ScreenWidth/A_ScreenHeight <= 1.8)
    {
    Goto, FirstRun
    }
    
    MsgBox, 21, Nvidia Surround Toggle, Error: Nvidia Surround is already enabled.
    IfMsgBox Retry
    Goto, DoubleCheck
    else
    Exit
    
    FirstRun:
    FileCreateDir, %A_AppData%\NVSToggle
    IniWrite, Completed, %A_AppData%\NVSToggle\NVSToggle.ini, NVSToggle, FirstRun
    
    
    ;==============================================================================================
    ; Determine current display state
    ;==============================================================================================
    DetectNow:
    IF (A_ScreenWidth/A_ScreenHeight <= 1.8)
    {
    Goto, ToggleOn
    }
    IF (A_ScreenWidth/A_ScreenHeight > 1.8)
    {
    MsgBox, 21, Nvidia Surround Toggle, Error: Nvidia Surround is already enabled.
    Exit
    }
    
    MsgBox, 16, Nvidia Surround Toggle, ERROR: Failed to determine current display state.
    Exit
    
    ;==============================================================================================
    ; Toggle-on routine (switch to Surround mode)
    ;==============================================================================================
    ToggleOn:
    WinActivate ahk_class Shell_TrayWnd
    Send {LCtrl down}
    Send {LAlt down}
    Send {s down}
    Sleep 100
    Send {LCtrl up}{LAlt up}{s up}
    Sleep 3500
    IF (A_ScreenWidth/A_ScreenHeight <= 1.8)
    {
    Goto, SurroundFail
    }
    Exit
    
    SurroundFail:
    MsgBox, 21, Nvidia Surround Toggle, Error: Nvidia Surround could not be enabled!
    ;FileDelete, %A_AppData%\NVSToggle\NVSToggle.ini
    Exit

    Disabling surround:
    Code:
    #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
    #Warn  ; Enable warnings to assist with detecting common errors.
    SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
    SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
    
    ;==============================================================================================
    ; First-run configuration
    ;==============================================================================================
    IniRead, FirstRunVar, %A_AppData%\NVSToggle\NVSToggle.ini, NVSToggle, FirstRun
    IF (FirstRunVar = "Completed")
    {
    Goto, DetectNow
    }
    
    MsgBox, 65, Nvidia Surround Toggle, To allow this application to configure itself for first-time use, please enable Nvidia Surround using the Nvidia Control Panel now. `n`nClick "OK" when ready, or "Cancel" to quit.
    IfMsgBox Ok
    Goto, DoubleCheck
    else
    Exit
    
    DoubleCheck:
    IF (A_ScreenWidth/A_ScreenHeight > 1.8)
    {
    Goto, FirstRun
    }
    
    MsgBox, 21, Nvidia Surround Toggle, Error: Nvidia Surround is already disabled.
    IfMsgBox Retry
    Goto, DoubleCheck
    else
    Exit
    
    FirstRun:
    FileCreateDir, %A_AppData%\NVSToggle
    IniWrite, Completed, %A_AppData%\NVSToggle\NVSToggle.ini, NVSToggle, FirstRun
    
    
    ;==============================================================================================
    ; Determine current display state
    ;==============================================================================================
    DetectNow:
    IF (A_ScreenWidth/A_ScreenHeight > 1.8)
    {
    Goto, ToggleOff
    }
    IF (A_ScreenWidth/A_ScreenHeight <= 1.8)
    {
    MsgBox, 16, Nvidia Surround Toggle, ERROR: Nvidia Surround is already disabled.
    Exit
    }
    
    MsgBox, 16, Nvidia Surround Toggle, ERROR: Failed to determine current display state.
    Exit
    
    ;==============================================================================================
    ; Toggle-off routine (switch to Extended Desktop mode)
    ;==============================================================================================
    ToggleOff:
    Send {Volume_Mute}
    WinActivate ahk_class Shell_TrayWnd
    Send {LCtrl down}
    Send {LAlt down}
    Send {s down}
    Sleep 100
    Send {LCtrl up}{LAlt up}{s up}
    Sleep 3500
    Send {Volume_Mute}
    Run %A_WinDir%\System32\DisplaySwitch.exe /extend
    ;WIN + P, Cursor up, RETURN, ESCAPE ans I have my 3 monitor extended Profile.
    IF (A_ScreenWidth/A_ScreenHeight > 1.8)
    {
    Goto, ExtendFail
    }
    Exit
    
    ExtendFail:
    MsgBox, 21, Nvidia Surround Toggle, Error: Nvidia Surround could not be disabled!
    ;FileDelete, %A_AppData%\NVSToggle\NVSToggle.ini
    Exit
     
    Last edited: Jul 24, 2016
  4. mstcobra

    mstcobra Member Guru

    Messages:
    126
    Likes Received:
    3
    GPU:
    GTX 1080 Ti (H2O)
    Thanks for the updates SaiBork!

    One weird thing I get with them though is it will error and say it could not enable surround even though it did indeed successfully enable it. It's almost like the script is not properly interpreting the <= statement in the last IF condition.
     

  5. discy

    discy Member

    Messages:
    16
    Likes Received:
    0
    GPU:
    Radeon
  6. Jhereck

    Jhereck Member

    Messages:
    15
    Likes Received:
    0
    GPU:
    r9 390

Share This Page