Modificare a livello di programmazione la risoluzione dello schermo?
-
03-07-2019 - |
Domanda
Esiste un modo per modificare a livello di programmazione la risoluzione dello schermo o abilitare / disabilitare più monitor in Windows XP? Ad esempio, per passare da 1024x768 con un monitor a 1280x104 su due monitor? Sarei molto interessato a una funzione win32 per farlo, ma tutto ciò che può essere legato a una scorciatoia di Windows sarebbe sufficiente.
Soluzione
Puoi usare EnumDisplayDevices per capire quali display hai a disposizione e EnumDisplaySettings per ottenere un elenco delle risoluzioni disponibili per i tuoi schermi. Usa ChangeDisplaySettings per impostare la risoluzione che ti serve.
Altri suggerimenti
Sì, ma non fa parte di .NET. Sarà necessario utilizzare, richiamare o scrivere un wrapper per accedere all'API Win32.
Vedi ChangeDisplaySettings e funzione correlata.
Qui puoi trovare un esempio di base.
Puoi facilmente scrivere questo script con http://www.autohotkey.com
Ecco uno script per lo scambio tra un monitor e due monitor con Windows + 1 e 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 menu
Send Adjust Screen Resolution
Send {enter}
WinWaitActive Screen Resolution
ControlClick ComboBox3
Send {PgDn}
Send {Up} ; Select "Show desktop only on 1"
Send {enter}
Sleep 3000 ; workaround - cannot select accept/revert window?
Send {left}
Send {enter} ; accept changes
Return
#2::
Send {LWin}
WinWaitActive Start menu
Send Adjust Screen Resolution
Send {enter}
WinWaitActive Screen Resolution
ControlClick ComboBox3
Send {PgDn}
Send {Up}
Send {Up} ; Select "Extend these displays"
Send {enter}
Sleep 3000 ; workaround - cannot select accept/revert window?
Send {left}
Send {enter} ; accept changes
Return
Leggere il link indicato è facile.
basta scaricare la dll the good to go ..
Screen Srn=Screen.PrimaryScreen;
int tempWidth=Srn.Bounds.Width;
int tempHeight=Srn.Bounds.Height;
Console.WriteLine("Current Screen width is {0} and height is {1}.",
tempWidth,
tempHeight);