Win11熄屏逻辑变了?

以前Win10用这个bat脚本仅关闭笔记本屏幕

rem turn off screen
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)

但现在到了Win11,发现这个似乎会让电脑处于睡眠状态?我后台运行了一个雷电模拟器在用微信读书的听书,用bat关屏发现听书直接停了

看起来应该没问题:

**SC_MONITORPOWER**
0xF170 Sets the state of the display. This command supports devices that have power-saving features, such as a battery-powered personal computer.
设置显示的状态。此命令支持具有省电功能的设备,例如电池供电的个人计算机。
The *lParam* parameter can have the following values:
lParam 参数可以具有以下值:

* -1 (the display is powering on)
-1(显示器正在开机)
* 1 (the display is going to low power)
1(显示器将进入低功耗状态)
* 2 (the display is being shut off)
2(显示屏正在关闭)

是不是其他的情况触发了睡眠

试了下 Sordum Monitor Off,笔记本显示器瞬间到了锁屏界面然后熄屏了,但按键盘和鼠标都无法再唤醒电脑,无奈只好长按电源键硬关机
1 楼推荐的 DisplayPowerOff 倒是熄屏后不会影响唤醒

然而,后台播放的音乐/微信读书还是停掉了

实在想不到能有啥东西触发睡眠,感觉就是 Win11 的问题
看有没有同样 Win11 用户运行此命令会同样进入睡眠吧

这个需要向 Sordum.org 发帖提意见了

你需要PowerToys Awake