A command line tool to change the display resolution and HDR state of computers running Windows.
usage: ResolutionSwitcher --version | --monitors | --monitor <ID> | --width <width> --height <height> --refresh <refresh> | hdr <true/false>
Command line tool to change Windows display settings
options:
-h, --help show this help message and exit
--monitors List all active monitors
--monitor MONITOR List all available modes for a monitor (e.g. \\.\DISPLAY1)
--version show program's version number and exit
--width WIDTH The width of the new display mode (e.g. 1920)
--height HEIGHT The height of the new display mode (e.g. 1080)
--refresh REFRESH The refresh rate of the new display mode (e.g. 144)
--hdr <true|false> Enable/Disable HDR on the monitor
List all available devices on the system
ResolutionSwitcherDisplay detailed information for device with identifier \\.\DISPLAY2
ResolutionSwitcher --monitor \\.\DISPLAY2Change the resolution of the primary display device
ResolutionSwitcher --width 1920 --height 1080 --refresh 60Change the resolution of device with identifier \\.\DISPLAY2
ResolutionSwitcher --width 1920 --height 1080 --refresh 60 --monitor \\.\DISPLAY2Enable HDR on device with identifier \\.\DISPLAY2
ResolutionSwitcher --hdr true --monitor \\.\DISPLAY2Disable HDR on the primary device
ResolutionSwitcher --hdr falseDisplay available help information
ResolutionSwitcher --helpThe tool is useful for scenarios where you need to programmatically change the resolution of a display, for example, during "do" and "undo" commands run as part of a Moonlight session via Sunshine.
These examples assume the application is installed at C:\Program Files\ResolutionSwitcher\ResolutionSwitcher.exe.
cmd /C "C:\Program Files\ResolutionSwitcher\ResolutionSwitcher.exe" --width %SUNSHINE_CLIENT_WIDTH% --height %SUNSHINE_CLIENT_HEIGHT% --refresh %SUNSHINE_CLIENT_FPS%cmd /C "C:\Program Files\ResolutionSwitcher\ResolutionSwitcher.exe" --hdr %SUNSHINE_CLIENT_HDR%cmd /C "C:\Program Files\ResolutionSwitcher\ResolutionSwitcher.exe" --width 3840 --height 2160 --refresh 144cmd /C "C:\Program Files\ResolutionSwitcher\ResolutionSwitcher.exe" --hdr falseThe tool is written in Python and uses the ctypes library to interact with the Windows API.
For distribution, the Python script is compiled into an executable using pyinstaller.
Sometimes when changing HDR state, the screen resolution may reset to a previous resolution. As far as I can tell, this is a behavior of the Windows API, so if that's happening to you, you might want to do an HDR change followed by a resolution change.