一、用BAT脚本关闭显示器
shutdown_monitor.bat
%windir%\System32\scrnsave.scr /s
二、用BAT调PowerShell脚本关闭显示器
RunPowerShellScript.bat
@echo off
powershell -NoProfile -ExecutionPolicy Bypass -File “TurnOffMonitor.ps1”
pause
TurnOffMonitor.ps1
Add-Type ‘[DllImport(“user32.dll”)]public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);’ -Name a -Namespace b
[b.a]::SendMessage(-1, 0x0112, 0xF170, 2)
Write-Host “The monitor is now turned off.” -ForegroundColor Green
效果:
显示器会黑屏,移动鼠标或键盘会恢复。