Last active
August 18, 2024 15:16
-
-
Save Arax20/9493799b3aa73e1fb69af8d4f1c72ba6 to your computer and use it in GitHub Desktop.
Allows rebinding of winkey to a shortcut without getting in the way of system winkey shortcuts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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. | |
LWin:: | |
Input, x, L1 ; Catches key after winkey | |
if (ErrorLevel = "NewInput") ; If catching was interrupted | |
{ | |
Send #+r ; Set this to your powertoys run shortcut | |
return | |
} | |
Send, #%x% ; Sends caught key + winkey | |
return | |
~LWin Up:: | |
Input, , L0 ; Interrupts key catching on winkey release | |
return |
LWin::
{
; Wait for 0.5 seconds (500 milliseconds)
KeyWait("LWin", "T0.5")
if !GetKeyState("LWin", "P") ; If the key is released before 0.5 seconds
{
Send("{Alt Down}{Space}{Alt Up}") ; Send Alt + Space
Return
}
; If the key is still held down after 0.5 seconds, allow normal behavior
Send("{LWin Down}")
KeyWait("LWin") ; Wait until the key is released
Send("{LWin Up}")
Return
}
Would love a better solution.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently having some issues with a bit of an edge case here. Windows currently uses higher function keys to handle events like touchpad taps, with 3 and 4 fingered taps translating to Win+Ctrl+Shift+F22 and Win+Ctrl+Shift+F24, respectively. For some reason the script seems to open up Run despite the extra keys being pressed. Perhaps they are too fast for AHK to deal with:
Not entirely certain how to go about fixing, but I'll experiment a little and see if I can find anything helpful