Powertoys: Cannot map key to "Sleep".

Created on 29 Jul 2020  ·  19Comments  ·  Source: microsoft/PowerToys

ℹ Computer information

  • Windows build number: 18362.959
  • PowerToys version: 0.19.2
  • PowerToy module: Keyboard Manager

📝 Provide detailed reproduction steps (if any)

  1. Click "Remap a key"
  2. Select Key on left side.
  3. Select "Sleep" on right side.

✔️ Expected result

Pressing the remapped key puts Windows to sleep.

❌ Actual result

Powertoys says "The following keys are unassigned and you won't be able to use them:", followed by the remapped key name.

📷 Screenshots

Screenshot_1
Screenshot_2

Issue-Bug Product-Keyboard Shortcut Manager

All 19 comments

This warning just means you loose the original functionality of the "Browser Home" key,
i.e. you won't be able to use it _like before_

Did you try to click "Continue Anyway" and see if it works?

You're right, the error doesn't seem to be the issue. If I map it to "z", for example, it does work despite the warning.

However, it appears that it will not initiate Sleep no matter which key I try to assign.

what keyboard is this? some of the 'special' keys aren't actually real keys so we can't remap.

@arjunbalgovind fyi

It's a Sculpt Ergonomic Keyboard for Business (PN 5KV-00001). It's doesn't have a suspend key on it, which is why I'm trying to remap something else to that function. I'm currently using AutoHotKey to do this, but am exploring whether I could use Powertoys instead.

Same issue here. Mapping a key or shortcut to sleep does not work. I'm on a Logitech ERGO K860.

Ditto. Using MS Natural Ergonomic Keyboard 4000.

The titular issue appears to have been resolved, and the new problem being discussed is also housed in #6020, for reference.

Never mind, we're apparently keeping this issue up.

As I mentioned in the other issue (now closed), I can reproduce this issue as well. I'm on an HP Notebook, which also lacks an actual sleep key. It would be great to see if this works for someone with an actual sleep key on their keyboard.

I can verify that Sleep does not work on my system either, using a Microsoft wireless 6000 keyboard (v3).

Issue #7247

I also have an issue with remapping keys to the sleep command. I'm using a Microsoft Wired Keyboard 600 (Model #: 1366). I first tried to remap the scroll lock to the sleep key. While it did successfully remap, whenever I try hitting the sleep key, the computer wouldn't go to sleep. After reading earlier posts in this issue thread, I thought the problem could be that I couldn't remap the scroll lock key. I then tried the caps lock key (which I know would remap, since I had been remapping it to the shift key). After remapping it, the "sleep" key still wouldn't work. I'm not sure what exactly the problem is. The problem, for me, doesn't seem to be with the key not remapping, rather that the sleep command simply doesn't work when I try issuing it.

For reference, I am using PowerToys version 0.21.1, and my build number is 18363.1082.

Tested this with two different keyboards connected at the same time:

  • Old DELL keyboard, mapped "start calculator" key to "Sleep": not working (mapping to e.g. "mute" works)
  • Slightly newer DELL keyboard with built-in "Sleep" key: when trying to map another key to "sleep" by pressing "sleep" key in the remappers "Type" mode: computer goes to sleep, remapper ignores keystroke.

Seems the "sleep" keystroke bypasses the keyboard mapper completely. It gets acted upon before the keystroke even reaches the remappers hook and emitting "sleep" from the remapper does nothing because the relevant system hook gets called before remap.

@ALfuhrmann
The VK_Sleep is a special key, I would expect it's processed at driver level and no event is passed to any high level application, remapping should not be possible using the current PowerToys architecture.

AutoHotKey can do it just fine, and is what I'm now using instead of the
PowerToy.

On 2020/10/29 7:34 am, Enrico Giordani wrote:

The VK_Sleep is a special key, I would expect it's processed at driver
level and no event is passed to any high level application, remapping
should not be possible using the current PowerToys architecture.

--
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub [1], or unsubscribe
[2].

Links:

[1]
https://github.com/microsoft/PowerToys/issues/5291#issuecomment-718793947
[2]
https://github.com/notifications/unsubscribe-auth/ALCXEDPZKMFTH2Z24VXR3PDSNF4PZANCNFSM4PLZKG3Q

@ddimick
I forgot to add @ALfuhrmann since I was replying to someone that is trying to remap the sleep key pressing the sleep key and when they do so, the computer goes to sleep.

Ah, pardon me. I understand your comment now.

@arjunbalgovind any insight here for the sleep key?

I have a feeling we can't remap the Sleep/Power key to something else (I haven't checked if AHK can do that), but for remapping to Sleep I think sending the VK_SLEEP key wouldn't do anything. Instead we would need to do something custom like calling a Win32 API which sets the system to sleep. I found the SetSuspendState API which can do this, but I don't know if it has any constraints such as running as admin or anything like that. VK_SLEEP is probably only processed by the OS or something like that, so using SetSuspendState seems like a better option than figuring out how to get VK_SLEEP to work.

It would be amazing if that API supported warning other system components about an impending sleep, ideally with a reason code of some sort. If that were the case, PowerToys could potentially intercept that signal (if initiated by the sleep key) as a proxy for the actual sleep keystroke, cancel the sleep action, and perform a new keystroke as normally occurs with remapped keys.

@LRitzdorf
I don't think it is possible since an application will never receive the information if the sleep event was generated by a key stroke or from Start menu or from any other source.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SWinxy picture SWinxy  ·  3Comments

amorenew picture amorenew  ·  3Comments

CombeeMike picture CombeeMike  ·  3Comments

patware picture patware  ·  3Comments

enricogior picture enricogior  ·  3Comments