Autohotkey: Remap Win key - when pressed alone

﹥>﹥吖頭↗ 提交于 2019-12-24 04:19:11

问题


Because of an insane laptop keyboard layout and the inability to map Fn-combinations I want to do a few remappings. I would like to use the LWin key as modifier (such as LWin+Right ==> End, etc.). It works just fine.

However, I want to stop LWin, when pressed and released alone, to bring up the Windows menu (b/c I sometimes press the modifier but then decide not to complete the action) and I still want to be able to access the Windows menu fairly easily, say via LAlt+LWin. (Obviously LWin must act as a proper modifier otherwise.)

So I tried:

#LAlt::Send {LWin}

which kinda works but ugly (needs LWin kept pressed while Alt is pressed and released). It would be more natural the other way round, i.e.

!LWin::Send {LWin}

but it doesn't work (not even with a $ or ~ prefix).

Worst of all I have had no success disabling the LWin key alone in such a way that it still works as a modifier:

LWin::Return

kills it completely.

I'm new to autohotkey (have had luck with keyboards, I guess ;)); what's a good way to solve these?


Update: here is my hotkey file in full so far:

#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)
;??????????????

回答1:


This should work:

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

Using Ctrl + Esc instead of LWin here does the trick.



来源:https://stackoverflow.com/questions/53067999/autohotkey-remap-win-key-when-pressed-alone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!