AutoHotkey 能够以各种不同的方式(SendRaw / SendInput / SendPlay / SendEvent)发送击键。我不太确定简单键::键映射使用什么方法,但它必须是其中之一。我的猜测是 SendRaw、SendInput、SendPlay 或 SendEvent 之一的工作方式与key :: key相同。
此外,#IfWinActive 有时不能完全按照您的预期工作,尤其是在全屏游戏中。所以我通常在没有#IfWinActive 的情况下测试我的 AHK 脚本,以确保它们正常工作。一旦它工作,我介绍条件。
更新
从http://www.autohotkey.com/docs/misc/Remap.htm:
启动脚本时,每个重新映射都会转换为一对热键。例如,包含a::b的脚本实际上包含以下两个热键:
*a::
SetKeyDelay -1 ; If the destination key is a mouse button, SetMouseDelay is used instead.
Send {Blind}{b DownTemp} ; DownTemp is like Down except that other Send commands in the script won't assume "b" should stay down during their Send.
return
*a up::
SetKeyDelay -1 ; See note below for why press-duration is not specified with either of these SetKeyDelays. If the destination key is a mouse button, SetMouseDelay is used instead.
Send {Blind}{b Up}
return
我的笔记:
我怀疑原因a::b
是有效的,但a::Send b
不是因为 a::b 如何将 button down 和 button up 处理程序分解为两个单独的映射。游戏的游戏循环可能会轮询游戏键的“keydown”状态,如果 AHK 正在合成重复,则不会始终保持这种状态。重新映射 a_down->b_down 和 a_up->b_up 可能会使 AHK 更准确地模拟按住键的行为,这对于以特定方式测试键状态的程序(GetAsyncKeyState?)可能很重要。
映射中的星号表示“即使按下了额外的修饰符,也要触发热键”。