新建txt文件

将下面内容复制到文件中

powershell (Add-Type '[DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)

修改txt后缀为bat

双击该bat文件,即可关闭屏幕。移动鼠标或点击键盘唤醒后,cmd程序也会自动关闭。

也可以在这里下载bat文件

脚本 Turn off screen
https://gallery.technet.microsoft.com/scriptcenter/Turn-off-screen-4d173e0a

如果想要通过键盘,关闭显示器,可以把这个bat文件重命名为off.bat,放在C:WINDOWSsystem32中。
之后就可以 win+r,然后输入off回车即可关闭显示器。

I found how to turn off screen in powershell http://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/how-can-i-turn-off-the-monitor-ie-put-it-to-sleep/0ea689fd-bc46-4329-8f2c-bf9967d18114?auth=1

This file is made to show that you can run C# commands in batch file, you can create a C# program to do this instaed.

The idea is to use SendMessage method from C#, import it to powershell and change to batch, because powershell doesn't provide a direct way to turn off the screen.

除了bat脚本,写一个C程序也可以达到目的。
https://www.tuziang.com/combat/347.html