Automatic Power Plan switch when HDMI is plugged in. Please help!


Just out of curiosity. Why don't you want to take advantage of working on 2 monitors? I myself already 2 have external monitors attached to my laptop while working but I still use the laptop screen as my 3rd monitor for emails and Teams chat. It is very convenient to work if you have multiple screens. Right now I only misery on your part trying to make this work when you can take advantage of multiple screens for convenience.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro
    Computer type
    PC/Desktop
    CPU
    AMD Ryzen 9 3900X
    Motherboard
    MSI MPG Gaming Edge Wifi (X570)
    Memory
    32GB Adata XPG DDR4
    Graphics Card(s)
    ASUS GTX 1070 8GB ROG
    Monitor(s) Displays
    LG Ultrawide 34"
    Screen Resolution
    3440x1440
    Hard Drives
    Main Boot Drive : 512GB Adata XPG RGB Gen3x4 NVMe M.2 SSD
    PSU
    EVGA 600 Watts Gold
    Case
    Deepcool Genome II
    Cooling
    Deepcool Fryzen
    Internet Speed
    1Gbps
    Browser
    Chrome
    Antivirus
    "Moderna"
  • Operating System
    Windows 11 Pro
    Computer type
    PC/Desktop
    CPU
    i7-4790K
    Motherboard
    ASRock Xtreme6 Z97
    Memory
    16GB Corsair Vengeance Pro
    Graphics card(s)
    MSI R9 290
    Monitor(s) Displays
    LG Ultrawide 34"
    Screen Resolution
    3440x1440
    Hard Drives
    Samsung M.2
    PSU
    Thermaltake 475 Watts 80 Bronze
    Case
    Thermaltake Commander I Snow Edition
    Cooling
    Deep Cool Archer Air Cooler
    Mouse
    Logitech G402
    Keyboard
    Armageddon MKA-5R RGB-Hornet
    Internet Speed
    1Gbps
    Browser
    Chrome
    Antivirus
    Moderna :)
badrobot - The OP's aim is to ease the transition between the computer display [only] and connecting/disconnecting external monitors. All the best, Denis
 

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447
Curtis,

In your next response, please would you tell me
- the full path to the folder containing your LidCloseAction-Sleep.bat and its shortcut,
and
- the exact filename you've used for the shortcut.

Then I'll be able to do the necessary work so that all you'll have to do is import what I give you into Task scheduler [I'll also tell you how to do the import].

I will explain everything afterwards to make sure you understand what's going on but it'll be quicker & easier for me to just give you the solution first.

All the best,
Denis
 
Last edited:

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447
badrobot - The OP's aim is to ease the transition between the computer display [only] and connecting/disconnecting external monitors. All the best, Denis
To be honest there's nothing hard about it. He just wants to automate it.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro
    Computer type
    PC/Desktop
    CPU
    AMD Ryzen 9 3900X
    Motherboard
    MSI MPG Gaming Edge Wifi (X570)
    Memory
    32GB Adata XPG DDR4
    Graphics Card(s)
    ASUS GTX 1070 8GB ROG
    Monitor(s) Displays
    LG Ultrawide 34"
    Screen Resolution
    3440x1440
    Hard Drives
    Main Boot Drive : 512GB Adata XPG RGB Gen3x4 NVMe M.2 SSD
    PSU
    EVGA 600 Watts Gold
    Case
    Deepcool Genome II
    Cooling
    Deepcool Fryzen
    Internet Speed
    1Gbps
    Browser
    Chrome
    Antivirus
    "Moderna"
  • Operating System
    Windows 11 Pro
    Computer type
    PC/Desktop
    CPU
    i7-4790K
    Motherboard
    ASRock Xtreme6 Z97
    Memory
    16GB Corsair Vengeance Pro
    Graphics card(s)
    MSI R9 290
    Monitor(s) Displays
    LG Ultrawide 34"
    Screen Resolution
    3440x1440
    Hard Drives
    Samsung M.2
    PSU
    Thermaltake 475 Watts 80 Bronze
    Case
    Thermaltake Commander I Snow Edition
    Cooling
    Deep Cool Archer Air Cooler
    Mouse
    Logitech G402
    Keyboard
    Armageddon MKA-5R RGB-Hornet
    Internet Speed
    1Gbps
    Browser
    Chrome
    Antivirus
    Moderna :)
Curtis,

This post explains the scripts-shortcuts to allow you to do what you want. The shortcuts use the Windows command PowerCfg so I start by explaining it in order to have less explanatory clutter in my explanations of the scripts-shortcuts themselves.
I will return later to explain how to automate the first of them [reaction to detecting an HDMI connection] but, as explained earlier on, I do not think the return action can be automated.


1 Intro: The built-in PowerCfg utility

You do not have to read this section but I think it will resolve doubts you might otherwise have when doing the job later on.

The solution uses the built-in Windows command PowerCfg [like all commands, it is actually in lowercase; I just type it that way because it helps me spot typos. Windows does not care either way.]

PowerCfg can be used to report power scheme properties and to change them.

PowerCfg’s full supporting documentation was last published a decade ago and is no longer even available to download. MS might well have altered details of the PowerCfg command for all any of us know. So I always adopt a cautious approach and double-check the effects of any command I use.
- You can see its built-in Help file still by using the command PowerCfg /? in a cmd/PS window.
- You can also see the guidance in
PowerCfg - SS64
Powercfg - MSDocs

PowerCfg can report many power scheme properties by using its /q switch but only by using the undocumented /qh switch can you be sure of getting all the properties. Quite why MS decided to have some properties as h, as hidden, is beyond any mortal.

The command
PowerCfg /qh
reports all the properties. I often find it handy to save them to a file by ‘piping’ the output to a file. There are a lot and they will appear to be an unintelligible mess.
PowerCfg /qh > “D:\Desktop\ThisPowerSchemeProperties.txt”
- Naturally, your version of this will need to use a convenient folder that exists on your computer.
- I’ve enclosed the folder path & filename in quotation marks. Doing so does not do any harm if when they are not needed. They ensure that the command will work correctly even if you have spaces or special characters such as ampersands in the folder path or filename.
- When I do this, I then open it in Word & replace all the double-spacing of lines so there are no blank lines left [Replace ^p^p with ^p] and then I copy what’s left into Excel so I can use its excellent filtering capabilities when I’m hunting for something.
- Generally-speaking, PowerCfg commands to report things can be run in any Cmd/PS window whilst altering properties requires Admin permission. Since any PowerCfg job I do involves both checking things & altering things, I tend to just open an Admin Cmd/PS window for the whole lot.

You can also get PowerCfg to report specific sections from the properties so you can focus on specific topics. For example,
PowerCfg /qh SCHEME_BALANCED SUB_BUTTONS LIDACTION > “D:\Desktop\ThisPowerSchemeProperties-LidCloseAction.txt”
will just report those properties within the Lid close action section.

I always check the properties both before & after changing anything because I find it easy to make mistakes in the very long command syntax that is often necessary. I checked them repeatedly when working out the commands you need to use. And I’m checking them repeatedly while typing this so I know I’m copying across from my notes accurately.
Confused on this section...

I downloaded the two batch files you attached and put them on my desktop (for now). I then also created a text file named 'ThisPowerSchemeProperties.txt'. I then ran PowerCfg /qh, copied the info is showed me and pasted it into ThisPowerSchemeProperties.txt.

I'm really not sure if I was supposed to do that?

I ran this:

C:\Users\Curtis>PowerCfg /qh SCHEME_BALANCED SUB_BUTTONS LIDACTION > "C:\Desktop\ThisPowerSchemeProperties-LidCloseAction.txt
The system cannot find the path specified.

(Changed from D to C).

Again, confused what I should ne doing here.

2 Please test the assumptions I’ve made

2.1 I think the Lid open action property is irrelevant, that it is a redundant property


I spotted a property that seemed relevant but testing it on my computers showed that it was not. Please run this command to check your computer.
powercfg /qh SCHEME_BALANCED SUB_BUTTONS LIDOPENWAKE
I think you will get this response
Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e (Balanced)
GUID Alias: SCHEME_BALANCED
Subgroup GUID: 4f971e89-eebd-4455-a8de-9e59040e7347 (Power buttons and lid)
GUID Alias: SUB_BUTTONS
Power Setting GUID: 99ff10e7-23b1-4c07-a9d1-5c3206d741b4 (Lid open action)
GUID Alias: LIDOPENWAKE
Possible Setting Index: 000
Possible Setting Friendly Name: Do nothing
Possible Setting Index: 001
Possible Setting Friendly Name: Turn on the display
Current AC Power Setting Index: 0x00000001
Current DC Power Setting Index: 0x00000001
which indicates that the computer is already set to turn on the display when the lid is opened.
If yours also shows the value 1 for the two final lines then we can conclude that it is not relevant to the job.

The main reason I was concerned was that I could not think of any circumstances in which you’d want it to be set any other way so I could not understand why the property even existed.

Here is what I got from running this command.

C:\Users\Curtis>powercfg /qh SCHEME_BALANCED SUB_BUTTONS LIDOPENWAKE
Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e (Balanced)
GUID Alias: SCHEME_BALANCED
Subgroup GUID: 4f971e89-eebd-4455-a8de-9e59040e7347 (Power buttons and lid)
GUID Alias: SUB_BUTTONS
Power Setting GUID: 99ff10e7-23b1-4c07-a9d1-5c3206d741b4 (Lid open action)
GUID Alias: LIDOPENWAKE
Possible Setting Index: 000
Possible Setting Friendly Name: Do nothing
Possible Setting Index: 001
Possible Setting Friendly Name: Turn on the display
Current AC Power Setting Index: 0x00000001
Current DC Power Setting Index: 0x00000001


2.2 I assumed that you only use the Balanced power plan

I only use the Balanced power plan but I do not know about you. If you have others that you want to script-shortcuts to apply to then I’ll only have to add additional lines to the scripts.

Please run this command
PowerCfg /l >”D:\desktop\PowerPlansList.txt”

If you only get the response
Existing Power Schemes (* Active)
-----------------------------------
Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e (Balanced) *


then that’s fine. If you get more than that and if you want to use the script-shortcuts for them all, please post your response and I’ll add the bits needed.

You do not need to wait. Setting everything up can still be done using what I’ve written below and you can add the necessary additional bits later on. I’m keen not to leave you dangling without any progress being made as I’ve done for the past week.
I use Balanced generally, but when I'm editing to turn it to performance. Connecting to my monitor is when I'l be editing so I would switch to performance. However, this really is a side issue and if it can't be done, it's not a big deal.

Please run this command
PowerCfg /l >”D:\desktop\PowerPlansList.txt”

Again confused, I don't have a PowerPlansList.txt file.

I apologise, that I really do not have any experience with CMD and scripts etc.
2.3 I assumed that you do not want to change your display timeout

When I connect to my external display, I do not change my display timeout. I’ve connected it to do some work so I’ll be using the keyboard and mouse and the display will stay on anyway. If I stop to make a pot of tea then I’m happy for the display to go off as normal until I return.

When, however, I connect to my TV I always set the display to stay on forever. I’ll be watching a film or TV recording on it so won’t be using the keyboard or mouse and therefore the display would otherwise turn off partway through.

If you want to do this as weel then just let me know.

You do not need to wait. Setting everything up can still be done using what I’ve written below and you can add the necessary additional bits later on.
I will only be connecting to a monitor and want to mimic a PC as much as possible, so the screen timing out is preferable.
3 Create the script to tell your computer to do nothing when the lid closes.

3.1 Write the script itself


LidCloseAction-DoNothing.bat
is attached anyway but I wanted to show you its content here as well.

powercfg /SetacValueIndex SCHEME_BALANCED SUB_BUTTONS LIDACTION 0 powercfg /SetdcValueIndex SCHEME_BALANCED SUB_BUTTONS LIDACTION 0 :: Pause to check during testing

If you would like to see any response while you are testing then you can temporarily remove the ∷ {colon colon space} so the window will stay open afterwards for you to have a look.
Okay so I ran the file, closed the laptop and it worked. I tried it both connected to HDMI and on it's own and the response is the same. So the short cut works, but nothing changes in terms of HDMI connection.

I ran the sleep batch file and it does work, but I noticed that both batch files arent hugely responsive:

I ran the Do Nothing, worked first time. I ran the sleep, and it didnt work. So I tried again. I then went back to Do nothing, and didnt work after first attempt.

For some reason the files dont work first time (apart from the very first time of the do not sleep) If you get what im saying.

Update:

Upon testing multiple times, it seems I have to run the desired batch file twice to get windows to switch power modes.
3.2 Store the script after testing

You can run the batch file to check that it works. You can run the command
powercfg /qh SCHEME_BALANCED SUB_BUTTONS LIDACTION
both before and after each test to check that the change has taken place. You can, of course, also check in Power options, Choose what closing the lid does. I just find it convenient to use the command window to do it.

When you are happy that the script works then you can put it in a permanent location. I put all my scripts within a [protected] C:\Tools folder that I have created for that purpose. See

Set up my Tools folder ditty - TenForums


3.3 Create a shortcut to the script

Create a shortcut in the normal way [right-click on the file, select Create shortcut].

I always trim of the .bat - Shortcut from a shortcut’s name because I don’t find it helpful. So LidCloseAction-DoNothing.bat - Shortcut.lnk becomes LidCloseAction-DoNothing.lnk assuming that you have set your File explorer to always show file extensions as I always do.

If you’ve put the script in a protected folder as I suggested above then Windows will say it cannot create it in the same place and will offer to create it on your Desktop instead. That will be fine.

Right-click on the shortcut and tell it to run minimised and set a particular icon if you want to. When you are happy with it, copy it back into the script’s folder [which will require Admin permission if you’ve protected the folder] and then you can move the shortcut to anywhere that’s convenient for you.

I will return to the uses of the shortcut later on when we discuss automating things.


4 Create the script to tell your computer to Sleep when the lid closes.

4.1 Write the script itself


LidCloseAction-Sleep.bat
is attached anyway but I wanted to show you its content here as well.

powercfg /SetacValueIndex SCHEME_BALANCED SUB_BUTTONS LIDACTION 1 powercfg /SetdcValueIndex SCHEME_BALANCED SUB_BUTTONS LIDACTION 1 :: Pause to check during testing

If you would like to see any response while you are testing then you can temporarily remove the ∷ {colon colon space} so the window will stay open afterwards for you to have a look.


4.2 Store the script after testing

You can run the batch file to check that it works. You can run the command

powercfg /qh SCHEME_BALANCED SUB_BUTTONS LIDACTION

both before and after each test to check that the change has taken place. You can, of course, also check in Power options, Choose what closing the lid does. I just find it convenient to use the command window to do it.

When you are happy that the script works then you can put it in a permanent location. I put all my scripts within a [protected] C:\Tools folder that I have created for that purpose. See

Set up my Tools folder ditty - TenForums


Once you are happy that both scripts work you can test both scripts one after the other to see the property changing back & forth each time.


4.3 Create a shortcut to the script

Create a shortcut in the normal way [right-click on the file, select Create shortcut].

I always trim of the .bat - Shortcut from a shortcut’s name because I don’t find it helpful. So LidCloseAction-Sleep.bat - Shortcut.lnk becomes LidCloseAction-Sleep.lnk assuming that you have set your File explorer to always show file extensions as I always do.

If you’ve put the script in a protected folder as I suggested above then Windows will say it cannot create it in the same place and will offer to create it on your Desktop instead. That will be fine.

Right-click on the shortcut and tell it to run minimised and set a particular icon if you want to. When you are happy with it, copy it back into the script’s folder [which will require Admin permission if you’ve protected the folder] and then you can move the shortcut to anywhere that’s convenient for you.

I will return to the uses of the shortcut later on when we discuss automating things.


5 This is, I believe, a useful halfway house

You can now do what you want more conveniently than before.

Ask any questions you want.

I will return to the question of automating LidCloseAction-DoNothing.bat so you can achieve what you set out to do. It’s a different topic and it involves use of both Event Viewer & Task Scheduler.

When this is all done, you might wish to automate the LidCloseAction-Sleep.bat as well [if only for experimentation] but your recent post seems to match my own results so I don’t think it is a viable course of action. Those interim Events while the external display is connected mean that LidCloseAction-Sleep.bat would run while you were still connected instead of only afterwards. But if you want to experiment then I’ll help you.





All the best,

Denis
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Huawei Matebook Pro
    CPU
    Intel(R) Core(TM) i7-10510U
    Memory
    16 Gb
    Graphics Card(s)
    NVIDIA GeForce MX250
    Sound Card
    Realtek Audio
Confused on this section...

I downloaded the two batch files you attached and put them on my desktop (for now). I then also created a text file named 'ThisPowerSchemeProperties.txt'. I then ran PowerCfg /qh, copied the info is showed me and pasted it into ThisPowerSchemeProperties.txt.

I'm really not sure if I was supposed to do that?

I ran this:

C:\Users\Curtis>PowerCfg /qh SCHEME_BALANCED SUB_BUTTONS LIDACTION > "C:\Desktop\ThisPowerSchemeProperties-LidCloseAction.txt
The system cannot find the path specified.

(Changed from D to C).

Again, confused what I should ne doing here.



Here is what I got from running this command.

C:\Users\Curtis>powercfg /qh SCHEME_BALANCED SUB_BUTTONS LIDOPENWAKE
Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e (Balanced)
GUID Alias: SCHEME_BALANCED
Subgroup GUID: 4f971e89-eebd-4455-a8de-9e59040e7347 (Power buttons and lid)
GUID Alias: SUB_BUTTONS
Power Setting GUID: 99ff10e7-23b1-4c07-a9d1-5c3206d741b4 (Lid open action)
GUID Alias: LIDOPENWAKE
Possible Setting Index: 000
Possible Setting Friendly Name: Do nothing
Possible Setting Index: 001
Possible Setting Friendly Name: Turn on the display
Current AC Power Setting Index: 0x00000001
Current DC Power Setting Index: 0x00000001



I use Balanced generally, but when I'm editing to turn it to performance. Connecting to my monitor is when I'l be editing so I would switch to performance. However, this really is a side issue and if it can't be done, it's not a big deal.

Please run this command
PowerCfg /l >”D:\desktop\PowerPlansList.txt”

Again confused, I don't have a PowerPlansList.txt file.

I apologise, that I really do not have any experience with CMD and scripts etc.

I will only be connecting to a monitor and want to mimic a PC as much as possible, so the screen timing out is preferable.

Okay so I ran the file, closed the laptop and it worked. I tried it both connected to HDMI and on it's own and the response is the same. So the short cut works, but nothing changes in terms of HDMI connection.

I ran the sleep batch file and it does work, but I noticed that both batch files arent hugely responsive:

I ran the Do Nothing, worked first time. I ran the sleep, and it didnt work. So I tried again. I then went back to Do nothing, and didnt work after first attempt.

For some reason the files dont work first time (apart from the very first time of the do not sleep) If you get what im saying.

Update:

Upon testing multiple times, it seems I have to run the desired batch file twice to get windows to switch power modes.
UPDATE

Okay so when I run each batch file, it seems to change the power options first time (I check on power options> what happens when lid is closed).

But for some reason, despite it telling me that the power mode has changed, I have to physically close the lid and open it and then re run the batch file for it to work... really strange.

So here is what happens on a step by step.

Laptop set to sleep on lid closing
I run the do not sleep batch
Shut the lid (connecting to HDMI so I can physically see that it works): and theres no change.
I open the lid
Run the do not sleep bath AGAIN
Close the lid and it works.

If I want to switch back to sleep:
Run sleep batch
close the lid
nothing
open the lid
run do not sleep batch
close the lid
success

Really strange

Note that no matter what batch is currently running, when I close the lid whilst it's hooked up to the TV, it's not that nothing happens, but the screen will kind of refresh or readjust, so it seems like something is still happening, even if the power modes hasn't changed.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Huawei Matebook Pro
    CPU
    Intel(R) Core(TM) i7-10510U
    Memory
    16 Gb
    Graphics Card(s)
    NVIDIA GeForce MX250
    Sound Card
    Realtek Audio
Curtis

1 Intro: The built-in PowerCfg utility
I downloaded the two batch files you attached and put them on my desktop (for now). I then also created a text file named 'ThisPowerSchemeProperties.txt'. I then ran PowerCfg /qh, copied the info is showed me and pasted it into ThisPowerSchemeProperties.txt.

I'm really not sure if I was supposed to do that?
That's fine. It's the long way round but there's nothing wrong with doing it that way.

I ran this:
C:\Users\Curtis>PowerCfg /qh SCHEME_BALANCED SUB_BUTTONS LIDACTION > "C:\Desktop\ThisPowerSchemeProperties-LidCloseAction.txt
The system cannot find the path specified.
(Changed from D to C).
When I said, "Naturally, your version of this will need to use a convenient folder that exists on your computer.", I did not mean to imply that your Desktop was at
C:\Desktop or at D:\Desktop.
I intended for you to choose any convenient folder that did exist.
If you have never taken deliberate action to "relocate" your Desktop folder then it will be at
C:\Users\%UserName%\Desktop
so test that by pasting that line into the File explorer address bar:-
- select and copy the whole of that line C:\Users\%UserName%\Desktop, funny symbols included
- click in part of the blank area in the right-hand side of your File explorer Address bar
where to click.png
- you'll see the existing location change to a 'selected' appearance
FE address bar.png
- now right-click and select Paste.
You'll see that it goes to your Desktop folder and shows you its contents.

You can use the same approach to the commands I gave you
PowerCfg /qh > “C:\Users\%UserName%\Desktop\ThisPowerSchemeProperties.txt”
PowerCfg /qh SCHEME_BALANCED SUB_BUTTONS LIDACTION > “C:\Users\%UserName%\Desktop\ThisPowerSchemeProperties-LidCloseAction.txt”
PowerCfg /l >”C:\Users\%UserName%\Desktop\PowerPlansList.txt”
I've also added these to my original post so you don't have to read multiple posts at the same time.

The reason this works is that %UserName% tells Windows to go off, find out what your UserName is and stick it in the expression.

I have a vague notion that I understand why you tried C:\Desktop but we can return to that later for a fuller discussion if you want.
- In File explorer, if you select ThisPC then you'll see what appear to be folders such as Desktop within it.
- However, they are not folders. They are disguised shortcuts to your folders and have caused mistakes before.
- Your folders are, by default, within C:\Users\%UserName% and that's where those disguised shortcuts take you.
- If you want to you can hide the disguised shortcuts and, for convenience, put your own folders within the File explorer, Quick access group to maintain easy access to them all.
- Make a note of these now and take a quick look at it but there's no need to do anything until you want to [if you want to]
Hide or Show User Profile Personal Folders - TenForumsTutorials
Pin or Unpin Folder Locations for Quick access - TenForumsTutorials
There are no ElevenForumTutorials yet and, when there are, they will be copies of the TenForumsTutorials version because both OS behave the same way in this respect.

I'll go through the next section of your reply now,
All the best,
Denis
 
Last edited:

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447
Oh, by the way, there's no need to quote the whole of my posts each time.
Just select the text you want to respond to then pause for a moment and you'll see
ElevenForum - quote selected text.png
and you can click on the Quote bubble and write whatever you want about it.
You can post that as it stands or you can select the next bit you want to respond to and do the same again and it will be added to your draft post underneath what you've already written.

Denis
 

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447
2 Please test the assumptions I’ve made
2.1 I think the Lid open action property is irrelevant, that it is a redundant property


Here is what I got from running this command.

C:\Users\Curtis>powercfg /qh SCHEME_BALANCED SUB_BUTTONS LIDOPENWAKE
Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e (Balanced)
GUID Alias: SCHEME_BALANCED
Subgroup GUID: 4f971e89-eebd-4455-a8de-9e59040e7347 (Power buttons and lid)
GUID Alias: SUB_BUTTONS
Power Setting GUID: 99ff10e7-23b1-4c07-a9d1-5c3206d741b4 (Lid open action)
GUID Alias: LIDOPENWAKE
Possible Setting Index: 000
Possible Setting Friendly Name: Do nothing
Possible Setting Index: 001
Possible Setting Friendly Name: Turn on the display
Current AC Power Setting Index: 0x00000001
Current DC Power Setting Index: 0x00000001

Good. That reinforces my assumption that all computers have those values already and that, therefore, we do not need to discuss that particular property any further.

2.2 I assumed that you only use the Balanced power plan

Now that I've clarified the commands, I think you'll be able to post the results of
PowerCfg /l >”C:\Users\%UserName%\Desktop\PowerPlansList.txt”
so I can see the "GUIDs" of your other power plans.
And tell me which plans you want to be able to use the batch files in.
I'll use this information to modify the batch files for all your intended plans.

You can also, if you wish, use the HDMI connection to change to your Performance power plan. That can be added to the batch file. And the disconnection batch file can have a command added to return you to the Balanced plan.

2.3 I assumed that you do not want to change your display timeout
the screen timing out is preferable
Fine.

Now, I'll look at the rest of your comments.

All the best,
Denis
 

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447
I noticed that both batch files arent hugely responsive:
I ran the Do Nothing, worked first time. I ran the sleep, and it didnt work. So I tried again. I then went back to Do nothing, and didnt work after first attempt.

For some reason the files dont work first time (apart from the very first time of the do not sleep) If you get what im saying.

Update:

Upon testing multiple times, it seems I have to run the desired batch file twice to get windows to switch power modes.

Oh. And you've tested it with
powercfg /qh SCHEME_BALANCED SUB_BUTTONS LIDACTION
and by looking in Power options, Choose what closing the lid does?

So it's not responding in the expected way despite looking okay in both those places?

By the way, the batch files run then stop when they have completed. So "Note that no matter what batch is currently running" should have been, "Note that no matter what batch was run last".
when I close the lid whilst it's hooked up to the TV, it's not that nothing happens, but the screen will kind of refresh or readjust, so it seems like something is still happening, even if the power modes hasn't changed
That seems normal.

I did not have this problem in testing. I don't know off the top of my head what might be going wrong. On the face of it, it seems like the whole attempt is going to fail.

I'll think and post again tomorrow.

All the best,
Denis
 

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447
In your next response, please would you tell me
- the full path to the folder containing your LidCloseAction-Sleep.bat and its shortcut,
and
- the exact filename you've used for the shortcut.
For the actual Batch files:
C:\Users\Curtis\Documents\Auto HDMI Power Switch\LidCloseAction-Sleep.bat
C:\Users\Curtis\Documents\Auto HDMI Power Switch\LidCloseAction-DoNothing.bat
C:\Users\Curtis\Documents\Auto HDMI Power Switch\ThisPowerSchemeProperties.txt


For the shortcuts (for now)

C:\Users\Curtis\Desktop\

PowerCfg /qh > “C:\Users\%UserName%\Desktop\ThisPowerSchemeProperties.txt”
Tried this: C:\Users\Curtis>PowerCfg /qh > "C:\Users\Curtis\Desktop\ThisPowerSchemeProperties.txt"

But nothing happened....
Now that I've clarified the commands, I think you'll be able to post the results of
PowerCfg /l >”C:\Users\%UserName%\Desktop\PowerPlansList.txt”
so I can see the "GUIDs" of your other power plans.
And tell me which plans you want to be able to use the batch files in.
I'll use this information to modify the batch files for all your intended plans.
I'm not sure if I have a PowerPlansList text file, but as you can see above, entering it in CMD doesnt seem to do anything.
You can also, if you wish, use the HDMI connection to change to your Performance power plan. That can be added to the batch file. And the disconnection batch file can have a command added to return you to the Balanced plan.
Switching to Performance when connecting to HDMI would be preferrable.
Oh. And you've tested it with
powercfg /qh SCHEME_BALANCED SUB_BUTTONS LIDACTION
and by looking in Power options, Choose what closing the lid does?
Okay so here is the results when the the lid function is at the default (sleep when closed)

C:\Users\Curtis>powercfg /qh SCHEME_BALANCED SUB_BUTTONS LIDACTION
Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e (Balanced)
GUID Alias: SCHEME_BALANCED
Subgroup GUID: 4f971e89-eebd-4455-a8de-9e59040e7347 (Power buttons and lid)
GUID Alias: SUB_BUTTONS
Power Setting GUID: 5ca83367-6e45-459f-a27b-476b1d01c936 (Lid close action)
GUID Alias: LIDACTION
Possible Setting Index: 000
Possible Setting Friendly Name: Do nothing
Possible Setting Index: 001
Possible Setting Friendly Name: Sleep
Possible Setting Index: 002
Possible Setting Friendly Name: Hibernate
Possible Setting Index: 003
Possible Setting Friendly Name: Shut down
Current AC Power Setting Index: 0x00000001
Current DC Power Setting Index: 0x00000001

This is what I have when I manually change the settings to do nothing when I close the lid

C:\Users\Curtis>powercfg /qh SCHEME_BALANCED SUB_BUTTONS LIDACTION
Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e (Balanced)
GUID Alias: SCHEME_BALANCED
Subgroup GUID: 4f971e89-eebd-4455-a8de-9e59040e7347 (Power buttons and lid)
GUID Alias: SUB_BUTTONS
Power Setting GUID: 5ca83367-6e45-459f-a27b-476b1d01c936 (Lid close action)
GUID Alias: LIDACTION
Possible Setting Index: 000
Possible Setting Friendly Name: Do nothing
Possible Setting Index: 001
Possible Setting Friendly Name: Sleep
Possible Setting Index: 002
Possible Setting Friendly Name: Hibernate
Possible Setting Index: 003
Possible Setting Friendly Name: Shut down
Current AC Power Setting Index: 0x00000000
Current DC Power Setting Index: 0x00000000
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Huawei Matebook Pro
    CPU
    Intel(R) Core(TM) i7-10510U
    Memory
    16 Gb
    Graphics Card(s)
    NVIDIA GeForce MX250
    Sound Card
    Realtek Audio
Damn.

The forum software is changing detail in my commands but I did not notice
- a space is being inserted where it should not be
- straight quotes are being replaced by curly quotes
and these make a difference.

PowerCfg /qh >"C:\Users\%UserName%\Desktop\ThisPowerSchemeProperties.txt"
PowerCfg /qh SCHEME_BALANCED SUB_BUTTONS LIDACTION >"C:\Users\%UserName%\Desktop\ThisPowerSchemeProperties-LidCloseAction.txt"
PowerCfg /l >"C:\Users\%UserName%\Desktop\PowerPlansList.txt"

Please post the results of the third one. The first two are just to inform you.

These are now correct [re-checked before & after posting],
What a palaver,
Denis
 

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447
You can make as many copies as you want elsewhere but please put the shortcut in the
C:\Users\Curtis\Documents\Auto HDMI Power Switch
folder and confirm its name. I'm expecting
C:\Users\Curtis\Documents\Auto HDMI Power Switch\LidCloseAction-DoNothing.lnk
but it's up to you as long as you tell me if it's different.

Got to go,
Denis
 

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447
1 Please copy this vbs script into the
C:\Users\Curtis\Documents\Auto HDMI Power Switch
folder. I have assumed that your shortcut is in that folder and is called [as mentioned above]
LidCloseAction-DoNothing.lnk
and I'll have to alter the script & give you the replacement if you've called it something else.

StartLidCloseAction-DoNothing.vbs [copy attached, you'll need to unzip it first]
Text version of the script written out but it is not being accepted - The line beginning WshShell.Run is not being accepted in my post when written as text
post.JPG

Running this vbs file runs the shortcut [it is an intermediary that the TS task will need to use]

2 I will also have to post a revised pair of batch files to suit your soon-to-be-posted PowerPlansList.txt i.e. the other power plans you want to use the batch files with.

3 I now have to write the Task scheduler entry that will detect the HDMI connection
- then run the vbs script
- that will run the batch file.
I'll test it on a couple on computers first to make sure it works. Back tomorrow.


All the best,
Denis
 

Attachments

  • StartLidCloseAction-DoNothing.zip
    433 bytes · Views: 2
Last edited:

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447
Curtis,

I have just finished the Task scheduler task that completes the set. But, during testing, I have discovered that there are other, entirely unrelated, EventID 112 events happening [which had not been the case when I first looked at those events in the middle of March].
So the whole notion of using EventID 112 to trigger automatic change to your on-lid-close action is a non-starter.

The batch files I gave you should work so shortcuts to them ought to be more convenient than going into Power options to do the change manually.
But you reported that you had to keep repeating the batch files before the changed setting operated as expected.

So I have been unable to help you at all. You might as well set your Lid close action to Do nothing all the time and have done with it.

Sorry not to be able to give you a better result,
Denis
 
Last edited:

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447
Curtis,

I have just finished the Task scheduler task that completes the set. But, during testing, I have discovered that there are other, entirely unrelated, EventID 112 events happening [which had not been the case when I first looked at those events in the middle of March].
So the whole notion of using EventID 112 to trigger automatic change to your on-lid-close action is a non-starter.

The batch files I gave you should work so shortcuts to them ought to be more convenient than going into Power options to do the change manually.
But you reported that you had to keep repeating the batch files before the changed setting operated as expected.

So I have been unable to help you at all. You might as well set your Lid close action to Do nothing all the time and have done with it.

Sorry not to be able to give you a better result,
Denis
Oh no, it felt so close. I feel like somebody should make a piece of software, or for the love of good please Microsoft make this a feature.

Thank you so much for helping me, it's just something I have to put up with. Also the monitor I bought (Huawei 23 inch) doesnt have any sound built in, so it that would have complicated it even further.

If you do think of anything let me know.

Curtis
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Huawei Matebook Pro
    CPU
    Intel(R) Core(TM) i7-10510U
    Memory
    16 Gb
    Graphics Card(s)
    NVIDIA GeForce MX250
    Sound Card
    Realtek Audio
Curtis,

Yes, it's a shame the masterplan did not work out. Those EventIDs were only recorded for the HDMI monitor connections & disconnections when I first looked at them and that was what made me think there could be an automatic solution.
Event viewer does clear out records in an unpredictable way and it must have just cleared them out before that first time I looked at them. Strange really, I hadn't just updated Windows or anything else.

Manually running those batch files ought to be more convenient then delving into power options manually.
But you said that they were unreliable in that the behaviour did not change even though the relevant power option did. That puzzled me.
If you do spot any pattern in the batch files having the desired effect & not doing so then do post back and perhaps we can work something out [even though it would have to remain a manually-triggered job each time].

All the best,
Denis
 

My Computer

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447

Latest Support Threads

Back
Top Bottom