Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- setlocal enabledelayedexpansion
- :: Script to toggle between Extend mode and Second Display Only mode
- :: Created by Claude - May 2, 2025
- title Display Mode Toggle
- echo Checking current display configuration...
- :: Use DisplaySwitch command to detect current display mode
- for /f "tokens=*" %%a in ('powershell -command "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Screen]::AllScreens.Count"') do set screen_count=%%a
- if %screen_count% LEQ 1 (
- echo Only one display detected or display is in single display mode.
- echo Attempting to switch to extended mode...
- DisplaySwitch.exe /extend
- echo Display mode changed to: EXTEND
- goto :end
- )
- :: Check if the display is currently extended
- :: We'll use a PowerShell command to check the current display state
- powershell -command "$displays = Get-WmiObject -Namespace root\wmi -Class WmiMonitorBasicDisplayParams; if($displays.Count -gt 1) { exit 0 } else { exit 1 }"
- if %errorlevel% EQU 0 (
- echo Current Display Mode: EXTEND
- echo Switching to Second Display Only...
- DisplaySwitch.exe /external
- echo Display mode changed to: SECOND DISPLAY ONLY
- ) else (
- echo Current Display Mode: SECOND DISPLAY ONLY
- echo Switching to Extend...
- DisplaySwitch.exe /extend
- echo Display mode changed to: EXTEND
- )
- :end
- echo.
- echo Operation completed.
- timeout /t 3 > nul
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement