用于更改监视器设置的 Windows 批处理文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1490004/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 13:12:11  来源:igfitidea点击:

Windows batch file to change monitor settings

windowsbatch-filemultiple-monitors

提问by Faken

I have a desktop computer that is hooked up to 3 different monitors of which only two can be active at any one time. One is a primary monitor and is always active. I can manually switch between the other two: one a monitor, another an HDTV.

我有一台台式电脑,它连接了 3 台不同的显示器,其中在任何时候都只能处于活动状态。一个是主监视器并且始终处于活动状态。我可以在另外两个之间手动切换:一个是显示器,另一个是 HDTV。

The switch is a mechanical switch which only handles VGA (and at that, only the RGB components are actually switched) so there is no feedback to the computer from the other devices, thus windows can not make any automatic adjustments to change resolutions and things like that.

该开关是一个机械开关,只处理 VGA(此时,实际上只切换 RGB 分量),因此其他设备没有反馈到计算机,因此 Windows 无法进行任何自动调整以更改分辨率等那。

I want to make a batch file that will automatically switch the screen configurations and resolutions (hard coding the proper resolutions of course since we can't detect the other devices anyways) so that they are correct for the displays.

我想制作一个批处理文件,它会自动切换屏幕配置和分辨率(当然,硬编码正确的分辨率,因为我们无论如何都无法检测到其他设备),以便它们适合显示器。

Where is the best place to get started? Where can I find library of commands (or whatever they are called) to do something like this? Lastly, is there anything I should be careful about when attempting something like this?

最好的起点是哪里?我在哪里可以找到执行此类操作的命令库(或它们的名称)?最后,在尝试这样的事情时有什么我应该小心的吗?

Thanks in advance,

提前致谢,

-Faken

-假的

回答by Tarnay Kálmán

Try reschangecon (yes, there is a console version!). It is safe, because it won't let you set settings that are not supported (without the force flag).

尝试 reschangecon(是的,有控制台版本!)。这是安全的,因为它不会让您设置不受支持的设置(没有 force 标志)。

http://www.12noon.com/displaychanger.htm(It is free for personal use)

http://www.12noon.com/displaychanger.htm(个人使用免费)

回答by lod3n

I've used ResSwitch to do this on my friend's HTPC that periodically forgot what resolution to drive his TV at, you call it like this: resswitch.exe 1920 1080 32 60

我已经使用 ResSwitch 在我朋友的 HTPC 上执行此操作,它会定期忘记驱动他的电视的分辨率,您可以这样称呼它:resswitch.exe 1920 1080 32 60

http://www.naughter.com/qres.html

http://www.naughter.com/qres.html

The risk is it doesn't ask you to confirm, so you better be sure your monitor can handle the resolution you're asking for.

风险在于它不会要求您确认,因此您最好确保您的显示器可以处理您要求的分辨率。