Use only Win key for PowerToys Run
RedAuburn opened this issue · comments
it would be great if the Win key (by itself) could be added as a shortcut for PowerToys Run, I know I have no reason to use the standard popup pane any more.
If you'd like to see this feature implemented, add a đź‘Ť reaction to this post.
for anyone who wants this now, you can remap the Win key to something like ctrl+space in the Keyboard Manager and set the PowerToys Run hotkey to ctrl+space
When PT Run is mature enough, this might actually not be such a bad idea.
tracked in #4203
for anyone who wants this now, you can remap the Win key to something like ctrl+space in the Keyboard Manager and set the PowerToys Run hotkey to ctrl+space
Unfortunately this will break all shortcuts that depend on the Windows key.
I solved with new PowerToys utility "keyboard manager" and remap "WinKey (Left)" to "Alt(Left)+Space" - the default shortcut for powertoys run - For me, it's amazing !!! :)
If you want to keep Win Key hotkeys (such as Win + R
) but also replace LWin Key with PowerToys Run, try this AHK Script I made:
;-----------------------------------------;
; Winkey PowerToys Run ;
;-----------------------------------------;
; Variables
replaceStartMenu := true
; Use replacement Start Menu, or activate Start Menu
LWin Up::
if (replaceStartMenu)
if (A_PriorKey = "LWin") ; A_PriorKey is the key that was last pressed
send {LWin Down}{Space Down}{LWin Up}{Space Up}
else
return
else
send {LWin}
return
return
; Toggle Start Menu Replacement, also allows Win Key Hotkeys to work
LWin & Space::
If replaceStartMenu
replaceStartMenu := false
else
replaceStartMenu := true
return
return
Making Win + Space
open the Start Menu causes some issues in both AHK and PowerToys Keyboard Manager that I do not currently know how to switch, so pressing this hotkey will toggle LWin between PowerToys Run and Start Menu instead! Also RWin is left untouched, but could also easily be added if you wanted that.
None of the mentioned method works well. The best option is to modify the source code to hook the windows key it self.
@modaresimr Were you able to modify the source code to hook the windows key, and if so, could you show/tell how so I can also do it?
@atimeofday I will send it when i found some free time.
I found a simple but great idea in superuser and modify it. Assuming that currently Alt
+Space
is mapped to your PowerToys Run
.
$LWin::
KeyWait, LWin, T0.2
If !ErrorLevel ; if you hold the LWin key for less than 200 miliseconds...
send {Alt Down}{Space Down}{Alt Up}{Alt Up}
Else ; but if it is held for more than that...
Send, {LWin Down} ; ...hold LWin down
KeyWait, LWin ; and, in both cases, wait for it to be released
Send, {LWin Up}
Return
Summary
You actually can map the windows key to Powertoys Run. Its a bit of a complicated process, but you can do it in the end. You need to install version 0.37.2 of powertoys, then map a key.
Process
- Uninstall your current version of Powertoys
- Install version 0.37.2 of Powertoys
- After the installation has completed, open it
- Go to
Keyboard Manager
- Map the windows key to something that you will use for Powertoys Run. In my case, I mapped
Win
toWin + Space
- It will say that the key combo cannot be mapped. Click map anyways.
- The key combo will actually be mapped.
- (optional) Install the newest version of powertoys, either from the github page, or from inside the app itself (settings->check for updates)
Final Product
@npxrc, if you do that, what happens when you press WIN+E, for example, to open the Explorer? What would be great is to have PowerToys Run on WIN key up, but keep every native shortcut that's made with WIN key.
@npxrc That isn't a working solution nor acceptable workaround. Re-mapping Win key will break every single shortcut that relies on Win key (Win + Tab, Win + E, Win + I, Win + X). It actually breaks more stuff than it fixes.
It's pretty easy if you want to put in an ounce of effort.
Bold statement considering it is coming from person who doesn't bother to even read like five comments below this issue.
@DarthJahus @jantajov Not quite sure what you're talking about. They still work perfectly fine when you press the combos.
Bold statement considering it is coming from person who doesn't bother to even read like five comments below this issue.
(@jantajov)
Bold statement considering it is coming from a person who doesn't bother to try the idea/solution before trying to prove the workaround as wrong + you're literally an armchair engineer.
btw i was killing two birds with one stone or whatever by doing two replies in one, the bottom half doesnt apply to darthjahus
@npxrc So the important part is to use version 0.37.2 for your solution? What changes in later versions make the workaround not working anymore?
FYI: I have a working solution with AutoHotkey (AHK).
- Map PowerToys Run hotkey to
Win (Left) + Space
- Install AutoHotkey
- Create a (text) file with
*.ahk
extension in%AppData%\Microsoft\Windows\Start Menu\Programs\Startup
- Paste the content below into that file and save.
- Run script (& runs automatically on Windows startup)
#NoTrayIcon
;-----------------------------------------;
; Winkey PowerToys Run ;
;-----------------------------------------;
; Use PowerToysRun as replacement for Start Menu
LWin Up::
Process, Exist, PowerToys.PowerLauncher.exe
if (ErrorLevel == 0) ; PTRun not running
send {LWin}
else ; PTRun is running
if (A_PriorKey = "LWin") ; A_PriorKey is the key that was last pressed
send {LWin Down}{Space Down}{LWin Up}{Space Up}
return
; Important: Allows Win Key Hotkeys to work
LWin & Space::
return
Remarks:
#NoTrayIcon
hides the AHK tray icon for that scriptProcess, Exist, PowerToys.PowerLauncher.exe
&if ErrorLevel
checks if PTRun is running. If so, [WinL] starts PTRun, otherwise it opens Start Menu
@modaresimr and @daniel-richter work really great, unless you have a second language/keyboard setup on windows, since LWin + Space changes that layout, I did a small change
LWin & Space::
-> RControl & Pause::
I still have a few problems, because, after a while, some other shortcuts(that I added via Keyboard manager and use the LWin key) stop working
Win(left) + enter -> Win(left) + Shift(left) + Right arrow key
Win(left) + Q -> Alt(left) + F4
Still trying to figure out what causes that.
@daniel-richter The issue is that when you try to map the windows key to anything really, it says "some of the commands you tried to map couldn't be mapped". If this was fixed in a recent update, then ignore the entire spiel that I had with my lil' tutorial, but it didn't work the last time i tried.
Came here for an answer but unfortunately found none.
I just replaced the windows+S shortcut with this, since win+s opens the start menu search anyways so this is a good drop-in replacement.
I would love to be able to just hit the windows key itself in its stead, though.
Came here for an answer but unfortunately found none.
I just replaced the windows+S shortcut with this, since win+s opens the start menu search anyways so this is a good drop-in replacement.
I would love to be able to just hit the windows key itself in its stead, though.
Its possible with AHK, however in a few occasions(more than I would like) the shortcuts get unresponsive, or a key is kept pressed ... either way would be great to have this build-in on powertoys itself, for sure!
@modaresimr and @daniel-richter work really great, unless you have a second language/keyboard setup on windows, since LWin + Space changes that layout, I did a small change
LWin & Space::
->RControl & Pause::
I still have a few problems, because, after a while, some other shortcuts(that I added via Keyboard manager and use the LWin key) stop working
Win(left) + enter -> Win(left) + Shift(left) + Right arrow key Win(left) + Q -> Alt(left) + F4
Still trying to figure out what causes that.
I was having the same problem, I believe it's because it's technically going: Down, Up, Down Up... in an infinite loop. I added to @daniel-richter's AHK script and I believe I was able to catch that.
#SingleInstance, Force
#NoTrayIcon
SendMode Input
;-----------------------------------------;
; Winkey PowerToys Run ;
;-----------------------------------------;
; Use PowerToysRun as a replacement for Start Menu
*LWin::SendInput, {Blind}{vk00}{Lwin Down} ; Added {Blind} so it doesn't force release keys to push down, just a safety precaution
Return
*LWin Up::
if (A_PriorKey = "LWin") { ;A_PriorKey is the key that was last pressed
Process, Exist, PowerToys.PowerLauncher.exe ;Checks if PowerRun is alive
if (ErrorLevel == 0){ ;PTRun not running
SendInput {Blind}{vk00}{LWin}
SendInput {Blind}{vk00}{LWin Up}
} else { ;PTRun is running
SendInput {vk00}{LWin Down}{Space Down}{vk00}{LWin Up}{Space Up} ; Launch PowerRun
SendInput, {vk00}{LWin Up}
}
} else {
if GetKeyState("LWin" "P") {
SendInput, {Blind}{vk00}{Lwin Down} ; If user still pressing win, stay down
} Else {
SendInput, {Blind}{vk00}{Lwin Up} ; Else, the release adds a null({vk00}) key to prevent the start menu from opening.
}
}
Return
; Important: Allows Win Key Hotkeys to work
LWin & Space::
Return
; Can remove the below, just a few extra touches I added for myself
#s:: SendInput {LWin Down}{vk00}{Space Down}{vk00}{LWin Up}{Space Up} ; Opens PowerRun when win+s
Return
#IfWinActive ahk_exe PowerToys.PowerLauncher.exe ; Check to see if PowerRun is the active window
{
; While in PowerRun
::vs::
SendInput,{TEXT} .Vis ; vs -> .Vis | for vs code("Visual Studio Code" in PowerRun), . is to search through programs
Return
Tab::SendInput, {Down} ; Tab -> ↓ | To tab through options, rather than going through the
#w::SendInput, {Up} ; Win + W -> ↑ | to move up through options
#s::SendInput, {Down} ; Win + S -> ↓ | to move down through options
; To prevent a miss click of win, I know I mess that up a lot
!w::SendInput, {Up} ; Alt + W -> ↑ | to move up through options
!s::SendInput, {Down} ; Alt + S -> ↓ | to move down through options
}
Hope this helps. Some things might seem redundant, like the *LWin::SendInput,
, but if I removed it seemed to pop up the start menu a lot more frequently. Note: On-Screen Keyboard will be finicky I'm using it just to show. Another Note: Spamming the win key will cause your start menu to pop up, up since AHK can't keep up, at least on my computer.
There's one thing I'm wondering, because in Open-Shell you can choose to have the Windows key do nothing (or open the custom menu).
It's a far shot, but it'd be lovely to have this implemented for PowerToys Run. I.e. an option to replace the regular start menu with Run. It won't help anyone coming here looking for a workaround though...
https://github.com/Open-Shell/Open-Shell-Menu/blob/master/Src/StartMenu/StartMenu.cpp
Here's a simple solution with AHK:
#NoEnv
SendMode Input
~LWin & F1::return ; Make LWin a prefix key (https://www.autohotkey.com/docs/v2/Hotkeys.htm#prefix)
LWin::^!+F24
Line 4 makes LWin a prefix key, which means that other existing bindings will still work as expected. You will have to check "Use centralized keyboard hook" in the Powertoys Run configuration. You can then start the script and change the activation shortcut. I am using Ctrl+Shift+Alt+F24 because that's very unlikely to interfere with any other shortcuts.
Here's a simple solution with AHK:
#NoEnv SendMode Input ~LWin & F1::return ; Make LWin a prefix key (https://www.autohotkey.com/docs/v2/Hotkeys.htm#prefix) LWin::^!+F24Line 4 makes LWin a prefix key, which means that other existing bindings will still work as expected. You will have to check "Use centralized keyboard hook" in the Powertoys Run configuration. You can then start the script and change the activation shortcut. I am using Ctrl+Shift+Alt+F24 because that's very unlikely to interfere with any other shortcuts.
This works so well omg
Thanks you so much
Here's a simple solution with AHK:
#NoEnv SendMode Input ~LWin & F1::return ; Make LWin a prefix key (https://www.autohotkey.com/docs/v2/Hotkeys.htm#prefix) LWin::^!+F24Line 4 makes LWin a prefix key, which means that other existing bindings will still work as expected. You will have to check "Use centralized keyboard hook" in the Powertoys Run configuration. You can then start the script and change the activation shortcut. I am using Ctrl+Shift+Alt+F24 because that's very unlikely to interfere with any other shortcuts.
+1 works very well. For most people, if you don't have F24 to map your PowerToys Run, just change the F24 to F5 and it works beautifully
The prefix key method by @xieve forces the Win
key to be a prefix and only a prefix, so that shortcut where Win
is used as a modifier but not a prefix, like Ctrl + Win + Left
does not work anymore. Here is a one-liner that does not have this problem.
Set your shortcut as Win + F12
, then run the following AHK
~LWin::F12
If you want to avoid using F12
, you can use for example F24
by editing ~\AppData\Local\Microsoft\PowerToys\PowerToys Run\settings.json
"open_powerlauncher": {
"win": true,
"ctrl": false,
"alt": false,
"shift": false,
"code": 135,
"key": ""
},
where code 135 is F24
, see https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes.
The above Autohotkey methods either suffer from impaired ability on win combo, or over-sensitivity when it's not intended (e.g. when pressing Win+V)
Here is a clean method using Python.
This program remaps LWin
to LWin+F12
while preserving all other behaviors.
import keyboard
class LWRemapper():
def __init__(self) -> None:
self.last_press_e = None
keyboard.on_press(self.handle_press)
keyboard.on_release_key('left windows', self.handle_lw_release, True)
keyboard.wait()
def handle_press(self, e: keyboard.KeyboardEvent) -> None:
self.last_press_e = e
def handle_lw_release(self, e: keyboard.KeyboardEvent) -> None:
if self.last_press_e.name == 'left windows':
keyboard.send('f12')
keyboard.release('left windows')
LWRemapper()
A c++ solution is provided here https://github.com/mkmark/lwin-remapper/releases/tag/v1.0.0.
@npxrc That isn't a working solution nor acceptable workaround. Re-mapping Win key will break every single shortcut that relies on Win key (Win + Tab, Win + E, Win + I, Win + X). It actually breaks more stuff than it fixes.
It's pretty easy if you want to put in an ounce of effort.
Bold statement considering it is coming from person who doesn't bother to even read like five comments below this issue.
I actually use this for a long time and it works perfectly fine. Here is what I've done:
- Since I am using very frequently PTR, I mapped it to Win + Backspace and then in the keyboard manager I've remapped win key to Win + Backspace as well. With this mapping, since backspace doesn't really count or do anything in any program, most of my shortcuts such as Win + E for explorer , Win + L for locking desktop, win+, for quickly peaking at desktop, Win + Tab and etc. are working perfectly fine. There are a few shortcuts that does not work properly such as win+; for emojis and Win + V for clipboard history. For those, in PowerToys, I've mapped my Right CTRL which I never use to the original Win key and in any occasion where I need that, I can use it just like the normal Win key. I am using this setup for a long time and can't say how I love to access everything so quickly from PTR.
So, ironically, the solution to this problem is actually in this thread. No AHK or Python needed. So, we use part of mkmark's answer.
Editing ~\AppData\Local\Microsoft\PowerToys\PowerToys Run\settings.json
"open_powerlauncher": {
"win": true,
"ctrl": false,
"alt": false,
"shift": false,
"code": 91,
"key": ""
},
But we set it to code 91 (code 91 being the Windows key), then save it.
Now, this kinda works, but the Windows menu pops up, closing it instantly.
We then use the program oddkms mentions, that being https://github.com/Open-Shell/Open-Shell-Menu so, install that, and during install, all you can disable the parts other than the shell menu part.
Then, once it launches, skip start menu style, go to basic settings, and set Windows key opens to nothing. If you want to use the regular Windows launcher, when you click on the symbol, set left click opens to Windows start menu.
Using this method, all Windows-based hotkeys still work, and I don't really see a downside to it other than having to install OpenShell. Hope it helps.
@Echo-Head-Wall's solution works great.
The only problem is that PowerToys Run shows on key_down
instead of key_up
(unpress). Which means it always shows on screen when you use WIN key for a shortcut (like WIN+E). I don't know if "key_down" is the entended behaviour for openning PowerToys Run 🤔
@Echo-Head-Wall's solution works great.
The only problem is that PowerToys Run shows on
key_down
instead ofkey_up
(unpress). Which means it always shows on screen when you use WIN key for a shortcut (like WIN+E). I don't know if "key_down" is the entended behaviour for openning PowerToys Run 🤔
hmmm yeah seems like they do that because they expect it to be a multi key anyways and feels snappier. at least once you finish the hotkey combo like win + r or win + e it goes away. i was looking at invoking it directly via openshells custom command call to see if thats on release but i cant seem to get the exe to actually open it which makes sense. i guess that is one downside to this solution
I don't remember where I found this, but I have been using it for a long time and it works great. No opening of the start menu, and stuff like Win + E still work. It maps the Win key to ctrl + shift + space, which is then set as shortcut in PowerToys Run. The only thing I haven't figured out is how to make it work as well with Autohotkey V2, but using V1 it works like a charm.
LWin:: Send, ^+{space}
;~ #w::SoundBeep
<#w::SoundBeep
;~ LWin & w::SoundBeep
for anyone who wants this now, you can remap the Win key to something like ctrl+space in the Keyboard Manager and set the PowerToys Run hotkey to ctrl+space
Would do this but wouldnt that break all the windows shortcuts (ex. Win+D to Desktop, or WinShiftS for Snip)?
I found a solution similar to @Echo-Head-Wall's, without the need to install OpenShell. Run window still momentarily pops up when using meta shortcuts.
- In keyboard manager, remap Win to an unused shortcut and remap the shortcut back to the other win key: (make sure to pick the same Left/Right keys)
- Remap a key - Win(Left) to Win(Right) + J
- Remap a shortcut - Win(Left) + J to Win(Right)
- Set the PowerToys Run activation shortcut to Win + J
All shortcuts using meta modifier seem to work, including ctrl+meta+arrows to switch virtual desktops.
Perhaps a better shortcut than Win + J can be found.
I found a solution similar to @Echo-Head-Wall's, without the need to install OpenShell. Run window still momentarily pops up when using meta shortcuts.
* In keyboard manager, remap Win to an unused shortcut and remap the shortcut back to the other win key: (make sure to pick the same Left/Right keys) * Remap a key - Win(Left) to Win(Right) + J * Remap a shortcut - Win(Left) + J to Win(Right) * Set the PowerToys Run activation shortcut to Win + J
All shortcuts using meta modifier seem to work, including ctrl+meta+arrows to switch virtual desktops. Perhaps a better shortcut than Win + J can be found.
this work for me although i cant get windows key shortcuts to work for example win + 1 to open the first app pinned to my taskbar
Win + "J" isn't ideal placeholder and some shortcuts do not work. I tried others but settled on a reserved keycode (for example VK 252) instead of "J". Configure the shortcuts in keyboard manager gui and edit ~\AppData\Local\Microsoft\PowerToys\PowerToys Run\settings.json:
"open_powerlauncher": {
"win": true,
"ctrl": false,
"alt": false,
"shift": false,
"code": 252,
"key": ""
},
What’s the benefit is using VK 252 over win + j?
Probably avoids some shortcut conflict. With Win + J, some windows shortcuts did work for me (like Win + E) but Ctrl + Win + arrowkeys did not. With Win + VK 252, all shortcuts seem to work. Only annoyance is the powertoys run menu activating on keydown along with other shortcut.
Win + "J" isn't ideal placeholder and some shortcuts do not work. I tried others but settled on a reserved keycode (for example VK 252) instead of "J". Configure the shortcuts in keyboard manager gui and edit ~\AppData\Local\Microsoft\PowerToys\PowerToys Run\settings.json:
"open_powerlauncher": { "win": true, "ctrl": false, "alt": false, "shift": false, "code": 252, "key": "" },
this fixed the issue for me. for anyone curious, after editing the json file and restarting powertoys this should be in your settings for Remap a Key in the Keyboard Manager of Powertoys (VK 252 is the last option in the drop down menu)
Is it possible to bind to Win key – only when its onkeyup
event, instead of onkeydown
?
I want to have other win-shortcuts to work without triggering any windows.