是否可以通过命令行将显示缩放比例更改为 150%?

是否可以通过命令行将显示缩放比例更改为 150%?

我发现这个批处理文件,它让我接近是否可以通过命令行更改显示比例?_ 。我想要一个批处理文件,它让我无需点击任何按钮就能达到 150%,而不是一个批处理文件 150.bat 和一个批处理文件 100.bat,它让我无需输入任何按钮就能达到 100%。这可能吗?

我可以将其命名为 100.bat

@ECHO OFF

explorer ms-settings:display
ping -n 2 127.0.0.1 > nul

:VBSDynamicBuild
SET TempVBSFile=%tmp%\~tmpSendKeysTemp.vbs
IF EXIST "%TempVBSFile%" DEL /F /Q "%TempVBSFile%"
ECHO Set WshShell = WScript.CreateObject("WScript.Shell") >>"%TempVBSFile%"
ECHO Wscript.Sleep 500 >>"%TempVBSFile%"
ECHO WshShell.SendKeys "{TAB 2}{UP 1}" >>"%TempVBSFile%"
ECHO Wscript.Sleep 500 >>"%TempVBSFile%"
ECHO WshShell.SendKeys "%%{F4}" >>"%TempVBSFile%"
CSCRIPT //nologo "%TempVBSFile%"

explorer ms-settings:display
ping -n 2 127.0.0.1 > nul


CSCRIPT //nologo "%TempVBSFile%"
EXIT

还有这个125.bat

@ECHO OFF

explorer ms-settings:display
ping -n 2 127.0.0.1 > nul

:VBSDynamicBuild
SET TempVBSFile=%tmp%\~tmpSendKeysTemp.vbs
IF EXIST "%TempVBSFile%" DEL /F /Q "%TempVBSFile%"
ECHO Set WshShell = WScript.CreateObject("WScript.Shell") >>"%TempVBSFile%"
ECHO Wscript.Sleep 500 >>"%TempVBSFile%"
ECHO WshShell.SendKeys "{TAB 2}{DOWN 1}" >>"%TempVBSFile%"
ECHO Wscript.Sleep 500 >>"%TempVBSFile%"
ECHO WshShell.SendKeys "%%{F4}" >>"%TempVBSFile%"
CSCRIPT //nologo "%TempVBSFile%"

explorer ms-settings:display
ping -n 2 127.0.0.1 > nul


CSCRIPT //nologo "%TempVBSFile%"
EXIT

但是,如果点击次数过多,他们可能会走得太远——如果我可以设置一个特定的数字而不是上下移动,我会喜欢它。

答案1

1.在使用之前sendkeys,将您将“交互”的界面带到前台,然后尝试发送输入:

ECHO;WScript.Sleep 500 : objShell.AppActivate "Settings"

2.如果需要多次发送 TAB "{TAB 2}{UP 1}",请使用:

ECHO WshShell.SendKeys "{TAB}{TAB}{UP}"

3.您需要更多%%转义符:

ECHO WshShell.SendKeys "%%{F4}"

ECHO WshShell.SendKeys "%%%{F4}"

4.无论界面中已经定义了什么值(在UPs/DOWn),您都需要重置(将其移到下拉菜单中的第 1 个位置),然后在列表中设置下面的项目x 次直到达到所需的列出值位置为止所必需的:

echo;objShell.SendKeys "{TAB}{TAB}{~}{UP}{UP}{UP}{UP}"
echo;objShell.SendKeys "{UP}{UP}{UP}{DOWN}{~}"

:: it seems like a paranoid way of doing it, but it works...


  • 要将显示缩放比例更改为100
@echo off & setlocal

mode con: cols=50 Lines=02
2>nul del/q /f %tmp%\_tmp_send_keys_.vbs"
set "_tmp_send_keys_=%tmp%\_tmp_send_keys_.vbs"
explorer ms-settings:display && ping -n 2 127.1 >nul 

:vbs_dynamic_build_100
2>nul del/q /f "%_tmp_send_keys_%" & >"%_tmp_send_keys_%" ^
    (
     echo;Set objShell=WScript.CreateObject("WScript.Shell"^)
     echo;WScript.Sleep 500 : objShell.AppActivate "Settings"
     echo;objShell.SendKeys "{TAB}{TAB}{~}{UP}{UP}{UP}{UP}"
     echo;objShell.SendKeys "{UP}{UP}{UP}{~}%%%{F4}"
    ) && cscript //nologo "%_tmp_send_keys_%"

>nul 2>&1 (
explorer ms-settings:display & ping -n 4 -4 127.1 
%_APPDIRR__%taskkill/FI "WindowTitle eq Settings*"
del/q /f "%_tmp_send_keys_%" & endlocal & goto :EOF)

  • 要将显示缩放比例更改为125
@echo off & setlocal

mode con: cols=50 Lines=02
2>nul del/q /f %tmp%\_tmp_send_keys_.vbs"
set "_tmp_send_keys_=%tmp%\_tmp_send_keys_.vbs"
explorer ms-settings:display && ping -n 2 127.1 >nul 

:vbs_dynamic_build_125
2>nul del/q /f "%_tmp_send_keys_%" & >"%_tmp_send_keys_%" ^
    (
     echo;Set objShell=WScript.CreateObject("WScript.Shell"^)
     echo;WScript.Sleep 500 : objShell.AppActivate "Settings"
     echo;objShell.SendKeys "{TAB}{TAB}{~}{UP}{UP}{UP}{UP}"
     echo;objShell.SendKeys "{UP}{UP}{UP}{DOWN}{~}"
     echo;objShell.SendKeys "%%%{F4}"
    ) && cscript //nologo "%_tmp_send_keys_%"

>nul 2>&1 (
explorer ms-settings:display & ping -n 4 -4 127.1 
%_APPDIRR__%taskkill/FI "WindowTitle eq Settings*"
del/q /f "%_tmp_send_keys_%" & endlocal & goto :EOF)

  • 要将显示缩放比例更改为150
@echo off & setlocal

mode con: cols=50 Lines=02
2>nul del/q /f %tmp%\_tmp_send_keys_.vbs"
set "_tmp_send_keys_=%tmp%\_tmp_send_keys_.vbs"
explorer ms-settings:display && ping -n 2 127.1 >nul 

:vbs_dynamic_build_150
>"%_tmp_send_keys_%" (
     echo;Set objShell=WScript.CreateObject("WScript.Shell"^)
     echo;WScript.Sleep 500 : objShell.AppActivate "Settings"
     echo;objShell.SendKeys "{TAB}{TAB}{~}{UP}{UP}{UP}{UP}"
     echo;objShell.SendKeys "{UP}{UP}{UP}{DOWN}{DOWN}"
     echo;objShell.SendKeys "{~}%%%{F4}"
    ) && cscript //nologo "%_tmp_send_keys_%"

>nul 2>&1 (
explorer ms-settings:display & ping -n 4 -4 127.1 
%_APPDIRR__%taskkill/FI "WindowTitle eq Settings*"
del/q /f "%_tmp_send_keys_%" & endlocal & goto :EOF)

  • 进一步阅读:

[√]VBScript 中的 SendKeys 方法

[√]*WshShell.SendKeys “字符串和/或发送键”

相关内容