Autohotkey:重新映射 Win 键 - 单独按下时

Autohotkey: Remap Win key - when pressed alone

由于疯狂的笔记本电脑键盘布局和无法映射 Fn 组合,我想做一些重新映射。我想使用 LWin 键作为修饰符(例如 LWin+Right ==> End 等)。效果很好。

但是,我想停止 LWin,当单独按下和释放时,调出 Windows 菜单(b/c 我有时按下修改器但随后决定不完成操作) 我仍然希望能够相当轻松地访问Windows 菜单,比如通过LAlt+LWin。 (显然,否则 LWin 必须充当适当的修饰符。)

所以我尝试了:

#LAlt::Send {LWin}

这有点管用,但很丑(需要在按住并释放 Alt 的同时按住 LWin)。反过来会更自然,即

!LWin::Send {LWin}

但它不起作用(即使使用 $~ 前缀也不行)。

最糟糕的是,我没有成功单独禁用 LWin 键 ,但它仍然可以用作修饰符:

LWin::Return

完全杀死它。

我是 autohotkey 的新手(我猜我在键盘方面运气不错 ;));有什么好的方法可以解决这些问题?


更新:这是我到目前为止的完整热键文件:

#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.
#InstallKeybdHook

; Win + arrows
*#Right::Send {End}
*#Left::Send {Home}
*#Down::Send {PgDn}
*#Up::Send {PgUp}

; Sane CapsLock: make it Shift, Shift+CapsLock as CapsLock
CapsLock::Shift
+CapsLock::CapsLock

; Alt-Win to Win (so that Win menu is accessible still)
;   and disable Win alone (so that it won't pop up with navigation)
;??????????????

这应该有效:

LWin up::return
<!Lwin::
    send ^{Esc}
return
<#right::
    send {end}
return

在这里使用 Ctrl + Esc 而不是 LWin 就可以了。

另一个解决方案,特别是对于那些想要根据 long-press 或 short-press 重新映射的人。


对于我来说,我只想防止start menu按下win键最后放弃下一个组合键……

~LWin::__Disable_LWin()
            __Disable_LWin() {
                Send, {Blind}{vkFF}
                if (TickCount_When_LWinPressedDown = 0) {
                    TickCount_When_LWinPressedDown := A_TickCount
                }
            }
LWin Up::__Enable_LWin_ForShortPress()
            __Enable_LWin_ForShortPress() {
                if (A_PriorKey == "LWin") {
                    if (A_TickCount - TickCount_When_LWinPressedDown < 800) {
                        Send, {Blind}{LWin}
                    }
                }
                TickCount_When_LWinPressedDown := 0
            }