-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot map key to "Sleep". #5291
Comments
This warning just means you loose the original functionality of the "Browser Home" key, 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:
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 |
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].
|
@ddimick |
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 tried to put in Win+Esc => Sleep mapping in order to replace software of my own that did the same thing. It doesn't work in PowerToys. Looking back at my source code from 2010 when such things were not uncommon, I was using P/Invoke to call keybd_event on User32.dll, sending a down event, immediately followed by an up event. This worked and still works flawlessly without elevated privileges. Would be great if PowerToys could do this. |
I am having the same issue. |
If I use qmk firmware keyboard and remap through qmk software it actually can put your pc in sleep. So I think if you own a keyboard that actually have a sleep key it should be working. |
I tried this again in 0.55.1 and the remap function itself works fine (I can remap to printscreen for example), but assigning the same key to sleep does not work. Whatever command "sleep" in PT is sending does not seem to be recognised. |
I assigned Ctrl + Home to sleep, however it won't recognize it and put the computer to sleep when I hit that shortcut |
This issue still seems to be active. Just tried multiple combinations and Sleep does not work. All others work fine. |
Remapping the SLEEP key to something else also does not work in PowerToys 0.64.1 |
According to You can only map a button that is physically available on your keyboard. |
So my work around for this issue is using method from: to run this command |
I'd be happy to help with this issue. I wish to deliver the following change in behavior: when the user presses the shortcut remapped to the "Sleep" ( I'm not that proficient with C++ (this is a first time I touched it in the last decade), but after some time tackling with a code base, I found the following possibly far too dirty and hacky solution, but it does work for me (PC goes to sleep when I press CTRL+SHIFT+1): Inside the KeyboardManagerEngineLibrary, at the
Please note, it will require linking to the Another note is I'm not confident how to process the errors properly from the API call in this project and if we need to do that at all. If anyone who maintains the KeyboardManager module has an idea how to integrate my change properly, please speak out, I'd be happy to follow and create a PR with your guidance. |
I see at least one major problem with my "solution": it doesn't reset keys state before going to sleep, so after waking up, the initial hotkey will still be "held". |
Looks like adding Updated my code example to reflect this finding. |
Problem is still not fixed. Sleep command does nothing (HP 300 keyboard). |
Is there a way to make this work? I use PowerToys exclusively for this one feature of having a Sleep button on my mechanical GMK67 keyboard. |
I'm having the same issue here and hoping for a solution after so much time it was reported |
Still have the issue. |
I m having the same issue too, can anyone help? |
This was mentioned earlier through creating a windows shortcut, but the latest version of PowerToys makes going to sleep via a keyboard shortcut even easier.
I also made a shortcut to shutdown using App: C:\Windows\System32\shutdown.exe , Args: /p |
Args: powrprof.dll,SetSuspendState 0,1,0 puts my computer into hibernate even though hibernate is not enabled. Is that possilbe? |
This is working for me, thank you! |
Hi, which version of Powertoy have this Run Program feature? |
Not working for me in Win11 2H24. Even running the command in the terminal does nothing. |
ℹ Computer information
📝 Provide detailed reproduction steps (if any)
✔️ 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
The text was updated successfully, but these errors were encountered: