プログラムで画面解像度を変更しますか?
-
03-07-2019 - |
質問
プログラムで画面解像度を変更したり、Windows XPで複数のモニターを有効/無効にする方法はありますか?たとえば、1台のモニターで1024x768から2台のモニターで1280x104に変更するには?私はこれを行うためのwin32関数に最も興味がありますが、Windowsのショートカットに結び付けられるものなら何でも十分です。
解決
EnumDisplayDevices を使用して、使用可能なディスプレイを把握できます。 EnumDisplaySettings を使用して、ディスプレイで利用可能な解像度のリストを取得します。 ChangeDisplaySettings を使用して、必要な解像度を設定します。
他のヒント
はい。ただし、.NETの一部ではありません。 Win32 APIにアクセスするには、ラッパーを使用、呼び出し、または記述する必要があります。
ChangeDisplaySettings を参照してください。関連関数。
こちらで基本的な例を見つけることができます。
を使用して、簡単にスクリプトを作成できます。
Windows + 1とWindows + 2を使用して1つのモニターと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
指定されたリンクを簡単に読んでください。
dllをダウンロードするだけです。
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);
所属していません StackOverflow