How To Disable Sleep Mode When An External Display Is Connected [Windows]

When you leave your system unattended for too long, it enters sleep mode. This is a standard feature that has been part of Windows for a long time. 有些应用程序, mostly media players, can circumvent this from happening. 例如, 在Windows 10 if you play a movie in the Moves & 电视应用, your system will not enter sleep mode. 当然, few apps support this. If you’re watching something on an external display, the system might enter sleep mode if you’re inactive too long. Here’s a simple way to disable sleep mode when an external display is connected.

In order to disable sleep mode when an external display is connected, you will need two power plans 在Windows. You will also need to find their GUIDs, and lastly, you will need to run an AutoHotKey script. This solution comes from SuperUser user miroxlav.

Create Power Plan

You can create two power plans, or just create one and make do with one of the other existing plans. One plan must have sleep mode enabled. Check your existing power plans and you will probably find one.

下一个, create a new power plan. Open File Explorer and go to Control PanelHardware and SoundPower Options. Click Create new plan on the left.

给它一个名字, and in the ‘Put the computer to sleep’ dropdowns, select ‘Never’ for both ‘On battery’ and ‘Plugged In’. 这就是所有你需要做的.

Find Power Plan GUID

Open a Command Prompt window and run the following command to find the GUID of your power plans.

powercfg /l

Copy them to a notepad file to use in the AutoHotKey script.

Disable Sleep Mode When External Display Is Connected

Open a Notepad file and paste the following in it.

OnMessage(0x219, "MsgMonitor")
 MsgMonitor(wParam, lParam, msg)
 if (wParam = 7) {
 Run, powercfg /s 381b4222-f694-41f0-9685-ff5bb260df2e
 } Else {
 Run, powercfg /s 381b4222-0001-2222-3333-000000000000
 MsgBox check %wParam% and %lParam% and decide to run programs with %msg%
 ;wParam: 7 lParam: 0 monitor connected
 ;wParam: 32772 lParam: 8977536 should be on disconected

In the above script, replace the GUID in this line “Run, powercfg /s 381b4222-f694-41f0-9685-ff5bb260df2e” with the GUID for the power plan that has sleep mode disabled.

下一个, replace the GUID in this line “Run, powercfg /s 381b4222-0001-2222-3333-000000000000” with the GUID of the power plan with sleep mode enabled. Save the file with the AHK extension and run it with AutoHotKey.

You can manually run this script whenever you connected an external monitor, or you can add it to your start-up items so that it is always running. It will automatically change power plans when you connect/disconnect an external monitor.



本网站使用的Akismet,以减少垃圾邮件. 了解您的意见如何处理数据.

我们使用cookies来给你最好的在线体验. 通过同意你接受使用cookies按照我们的Cookie政策.