PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

Cannot use keyboard to wake laptop after put it to sleep with PowerToys run "sleep"

Open TonyWW opened this issue 3 years ago • 8 comments

Microsoft PowerToys version

v0.55.2

Running as admin

  • [X] Yes

Area(s) with issue?

PowerToys Run

Steps to reproduce

in PowerToys Run, type sleep, hit Enter. Then hit any keys on the external usb keyboard to try wake the laptop.

✔️ Expected Behavior

the PowerToys Run "sleep" should behave the same as the one that you on the Windows menu Power option. Or provide a setting to be the same.

❌ Actual Behavior

cannot wait laptop with usb keyboard

Other Software

No response

TonyWW avatar Feb 27 '22 14:02 TonyWW

notes: desktop w/ bluetooth keyboard, both win11 + PT Run act same.

may need to look at last var from NativeMethods.SetSuspendState and flip to false

crutkas avatar Feb 27 '22 17:02 crutkas

laptop can confirm behavior from @tonyww. May be just as simple as tweaking https://github.com/microsoft/PowerToys/blob/main/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.System/Main.cs#L159

to false, false, false or false, true, false

crutkas avatar Feb 27 '22 17:02 crutkas

I'll try it

lncubus avatar Mar 09 '22 13:03 lncubus

May be just as simple as tweaking to false, false, false or false, true, false

Unfortunately that's not so simple. The call to SetSuspendState puts machine in Sleep or Hibernate, but both states require Power button click, What we're trying to achieve is StandBy state.

Both calls goes

Rundll32.exe Powrprof.dll,SetSuspendState Sleep
Rundll32.exe Powrprof.dll,SetSuspendState Standby

lncubus avatar Mar 14 '22 14:03 lncubus

Investigated Explorer handling "Sleep" button. Dump with API Monitor shows several calls to NtPowerInformation. It is unclear how to reproduce Explorer behavior. Probably the right thing would be call to undocumented NtInitiatePowerAction.

lncubus avatar Mar 24 '22 02:03 lncubus

@lncubus , did you try anything else?

jaimecbernardo avatar Jun 22 '22 16:06 jaimecbernardo

Should be the same thing as https://github.com/microsoft/PowerToys/issues/10557

AkazaRenn avatar Feb 17 '23 00:02 AkazaRenn

I used SleepOnLan and found 'sleep' actually hibernates #10557 which is dup of this issue.

C:\\Windows\\System32\\rundll32.exe powrprof.dll,SetSuspendState 0,1,1

Note: My PC comes with tranditional sleep (entering S3 state) not modern sleep (entering Modern Standby).

fuweichin avatar Dec 20 '23 07:12 fuweichin

3 years later, this is very much still an issue, and exists with the new CmdPal just as it does with PT Run. (Not sure if issues on here can be labeled for two different PowerToys modules, but if so it would benefit from that.)

mkacct avatar Jun 13 '25 02:06 mkacct

Make sense that it'd be the same for Run and CmdPal - both share the same implementation for their system commands.

zadjii-msft avatar Sep 29 '25 15:09 zadjii-msft