;==============================================================================================
; First-run configuration
;==============================================================================================
IniRead, FirstRunVar, %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 not enabled.
IfMsgBox Retry
Goto, DoubleCheck
else
Exit
FirstRun:
FileCreateDir, %appdata%\NVSToggle
IniWrite, Completed, %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)
{
Goto, ToggleOn
}
IF (A_ScreenWidth/A_ScreenHeight = 1.8)
{
Goto, ToggleOn
}
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 C:\Program Files (x86)\DisplayFusion\displayfusioncommand.exe -monitorloadprofile "144hz y 60hz"
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
}
IF (A_ScreenWidth/A_ScreenHeight = 1.8)
{
Goto, SurroundFail
}
Exit
SurroundFail:
MsgBox, 21, Nvidia Surround Toggle, Error: Nvidia Surround could not be enabled!
FileDelete, %appdata%\NVSToggle\NVSToggle.ini
Exit