Site icon TechGit

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

windows-power-plan-guid-5495031

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. Some apps, mostly media players, can circumvent this from happening. For example, in Windows 10 if you play a movie in the Moves & TV app, your system will not enter sleep mode. Of course, 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 in 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.

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

Give it a name, and in the ‘Put the computer to sleep’ dropdowns, select ‘Never’ for both ‘On battery’ and ‘Plugged In’. That’s all you need to do.

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.

windows-power-plan-guid-5495031

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.

Next, 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.

Source

FacebookTwitterTumblrRedditLinkedInHacker NewsDiggBufferGoogle ClassroomThreadsXINGShare
Exit mobile version