我想制作一个简单的 .bat 文件,根据屏幕使用情况设置正确的显示选项。你能帮我吗?
我不知道到目前为止我所做的事情有什么问题,但是我对 cmd 的经验很少...
#retrive virtual Screen with to compare to working area
set VSW= [System.Windows.Forms.SystemInformation]::VirtualScreen.Width
set WAW = [System.Windows.Forms.SystemInformation]::WorkingArea.width
#comparing and chose diplay option
if %WAW% leq %VSW% (
displayswitch.exe /clone
) else
displayswitch.exe /extend
答案1
要获得语法正确的 powershell 脚本:
#retrive virtual Screen with to compare to working area
Add-Type -Assembly System.Windows.Forms
$VSW = [System.Windows.Forms.SystemInformation]::VirtualScreen.Width
$WAW = [System.Windows.Forms.SystemInformation]::WorkingArea.width
#comparing and chose diplay option
if (%WAW% -le %VSW%){
displayswitch.exe /clone
) else {
displayswitch.exe /extend
}
但它在双显示器系统或侧边栏等系统中无法很好地工作。