Nicolas Goy
Nicolas Goy

Reputation: 1430

Send only if key was pressed alone

I'd like to remap my windows key to something else, but also I'd like to keep all windows key based shortcut.

In pseudo code it would be something like this:

when LWin Down until LWin Up if not LWin down abort else execute command

Upvotes: 3

Views: 727

Answers (1)

Relax
Relax

Reputation: 10568

Release the left windows key within 0,3 seconds after pressing it, to do something else (e.g. to send a):

~LWin::
KeyWait, LWin
return

~LWin Up::
Send {LWin Up}
If (A_PriorHotKey = "~LWin" AND A_TimeSincePriorHotkey < 300)
    Send, a
; else  ; another action after long press (not recommendet)
    ; Send, b
return

EDIT:

Try also this:

LWin up::
If (A_PriorKey = "LWin")
    Send a
return

; In this case its necessary to define a custom combination by using "&" or "<#" 
; to avoid that LWin loses its original function as a modifier key:

<#d:: Send #d  ; <# means LWin

Upvotes: 4

Related Questions