;The starting setup is as follow
;Monitor 1 is primary monitor with the display order 1->2->3
;We will enable/disable 2,3
$file = FileExists (@TempDir & "\run.ini")
if $file = 0 then
IniWrite(@TempDir & "\run.ini", "section", "runs", "0")
Else
$var = IniRead(@TempDir & "\run.ini", "section", "runs", "default")
;This is to turn monitors 2 and 3 OFF.
;Turn monitor 3 OFF first, then 2.
if $var = 0 Then
; exec cpanel app `display settings
Run("C:\WINDOWS\system32\control.exe desk.cpl,@0,3")
; wait for window to be active
WinWaitActive("Display Properties")
; select 3rd display
Send("{3}")
; work back to the ‘extend desktop’ controls
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
; toggle ‘extend desktop’ control and apply
Send("{SPACE}")
;select 2nd display
Send("{2}")
; work back to the ‘extend desktop’ controls
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
; toggle ‘extend desktop’ control and apply
Send("{SPACE}")
Send("{ENTER}")
IniWrite(@TempDir & "\run.ini", "section", "runs", "1")
Else
;This is to turn monitors 2 and 3 ON.
;Turn monitor 2 ON first, then 3.
; exec cpanel app `display settings
Run("C:\WINDOWS\system32\control.exe desk.cpl,@0,3")
; wait for window to be active
WinWaitActive("Display Properties")
; select 2nd display
Send("{2}")
; work back to the ‘extend desktop’ controls
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
; toggle ‘extend desktop’ control and apply
Send("{SPACE}")
;select 3nd display
Send("{3}")
; work back to the ‘extend desktop’ controls
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
Send("+{TAB}")
; toggle ‘extend desktop’ control and apply
Send("{SPACE}")
Send("{ENTER}")
IniWrite(@TempDir & "\run.ini", "section", "runs", "0")
EndIf
EndIf