Last active
March 20, 2024 17:07
-
-
Save james-hinton/12a7899caae915f16e2f614f97b3be6c to your computer and use it in GitHub Desktop.
A PowerShell script for quickly toggling between duplicate and extend display modes on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Path to custom registry key for tracking display mode | |
$registryPath = "HKCU:\Software\CustomDisplayToggle" | |
$keyName = "DisplayMode" | |
if (-not (Test-Path $registryPath)) { | |
New-Item -Path $registryPath -Force | Out-Null | |
New-ItemProperty -Path $registryPath -Name $keyName -Value "Duplicate" -PropertyType String -Force | Out-Null | |
} | |
Start-Sleep -Seconds 1 | |
$currentMode = (Get-ItemProperty -Path $registryPath).$keyName | |
if ($currentMode -eq "Duplicate") { | |
# switch to Extend | |
DisplaySwitch.exe /extend | |
Set-ItemProperty -Path $registryPath -Name $keyName -Value "Extend" | |
} else { | |
# switch to Duplicate | |
DisplaySwitch.exe /clone | |
Set-ItemProperty -Path $registryPath -Name $keyName -Value "Duplicate" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment