Programmatically change screen resolution? Programmatically change screen resolution? windows windows

Programmatically change screen resolution?


You can use EnumDisplayDevices to figure out what displays you have available and EnumDisplaySettings to get a list of available resolutions for your displays. Use ChangeDisplaySettings to set the resolution you need.


Yes, but its not part of .NET. You will need to use, invoke or write a wrapper to access the Win32 API.

See ChangeDisplaySettings and related function.

Here you can find a basic example.


You can easily script this with http://www.autohotkey.com

Here's a script for swapping between one monitor and two monitors with Windows+1 and Windows+2

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.#Warn  ; Recommended for catching common errors.SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.#1::Send {LWin}WinWaitActive Start menuSend Adjust Screen ResolutionSend {enter}WinWaitActive Screen ResolutionControlClick ComboBox3Send {PgDn}Send {Up} ; Select "Show desktop only on 1"Send {enter}Sleep 3000 ; workaround - cannot select accept/revert window?Send {left}Send {enter} ; accept changesReturn#2::Send {LWin}WinWaitActive Start menuSend Adjust Screen ResolutionSend {enter}WinWaitActive Screen ResolutionControlClick ComboBox3Send {PgDn}Send {Up}Send {Up} ; Select "Extend these displays"Send {enter}Sleep 3000 ; workaround - cannot select accept/revert window?Send {left}Send {enter} ; accept changesReturn