3

I've installed Microsoft PowerToys and I want to configure PowerToys Run so that it launches when I press the Windows key on the keyboard.

The settings allow me to change the keyboard shortcut to something like Windows-R, but changing it to just Windows does not seem to be permitted.

I already am used to pressing Windows when I want to type the name of an application that I want to launch, and I want to use PowerToys Run instead of the default Windows behaviour because it is offline and faster. I would like to use the Windows key so that I don't have to retrain my muscle memory.

Flimm
  • 10,730

5 Answers5

3

I found this to work faster for me then the timeout ahk method: I have powertoys run setup to use win+control+alt+shift+f to launch

#InstallKeybdHook
#Persistent
SetWinDelay, -1
SetControlDelay, -1
SetKeyDelay, 0

~LWin::vkFF ~RWin::vkFF ; Map RWin to the same virtual key code

~LWin Up:: ~RWin Up:: ; Include RWin Up event as well

If (A_PriorKey = "LWin" or A_PriorKey = "RWin")
{
Send, ^!#^+f
}
Return

Jolly
  • 39
2

The idea in this answer was great, however, attempting to have it run PowerToys.exe didn't work. I've used that idea to create the following script that is working well.

Assuming that Alt+Space is currently mapped to your PowerToys Run, using AutoHotkey:

$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

After installing AutoHotKey, put the above text in a file with an .ahk extension and double-click on it. Then short-press press the (Windows) key to see the result.

Of course, if you have PowerToys Run mapped to some other key chord, then make the appropriate adjustments in the script above to have it simulate pressing those keys.

NotTheDr01ds
  • 28,025
Ali
  • 294
1

It's actually possible to remap a tap on the left Windows key to doing something, while distinguishing it from the long press that is required when using this key as part of a shortcut such as Win+R.

You may use the free AutoHotkey.

The following script will do this. Replace if necessary the path to the powertoys executable (code modified as influenced by comment and answer of user Ali):

$LWin::
KeyWait, LWin, T0.2
If !ErrorLevel              ; if you hold the LWin key for less than 200 miliseconds...
    send {Alt Down}{Space Down}{Space Up}{Alt Up}   ; ...run powertoys launcher
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

After installing AutoHotKey, put the above text in a .ahk file and double-click it to test. You may stop the script by right-click on the green H icon in the traybar and choosing Exit. To have it run on login, place it in the Startup group at
C:\Users\USER-NAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.

Useful AutoHotkey documentation:

harrymc
  • 498,455
0

I've been looking for a way to reliably launch PowerToysRun using the Windows key to replace the default start menu.

Specifically, I found that other methods would not reliably direct text focus to the PowerToysRun searchbox. In some cases, the text field focus would remain on the underlaying window. This code adjusts some of the ideas here, but immediately 'activates' the powertoysrun window. As such, the focus is reliably pulled into PowerToysRun:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

;-----------------------------------------; ; 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} Sleep, 50 ; Wait for 50 milliseconds WinActivate, PowerToys.PowerLauncher ; Activate the PowerToys Run window to pull text field focus. } else { Sleep, 10 ; Wait for 10 milliseconds } 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

0

@Jolly's AHK script worked superbly. Note that it's AHK v1. For v2 use the one below. It's basically the same but has v2 syntax.

InstallKeybdHook()
Persistent
SetWinDelay(-1)
SetControlDelay(-1)
SetKeyDelay(0)

~LWin::vkFF ~RWin::vkFF ; Map RWin to the same virtual key code

~LWin Up:: ~RWin Up:: ; Include RWin Up event as well

{ ; V1toV2: Added bracket global ; V1toV2: Made function global If (A_PriorKey = "LWin" or A_PriorKey = "RWin") { Send("^!#^+f") } Return } ; V1toV2: Added bracket in the end

Richard
  • 31