microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
111.26k stars 6.54k forks source link

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

Open TonyWW opened 2 years ago

TonyWW commented 2 years ago

Microsoft PowerToys version

v0.55.2

Running as admin

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

crutkas commented 2 years ago

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 commented 2 years ago

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

lncubus commented 2 years ago

I'll try it

lncubus commented 2 years ago

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 commented 2 years ago

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.

jaimecbernardo commented 2 years ago

@lncubus , did you try anything else?

AkazaRenn commented 1 year ago

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

fuweichin commented 10 months ago

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).