1

所以我有这个游戏,叫AirMech。它还不能将鼠标按钮识别为控件,所以我尝试使用 AutoHotkey 来规避它,直到它被实现。

#IfWinActive, AirMech
  XButton1::Send c

没用。所以我尝试了SendGameSendPlay其他一切,也没有工作。我用谷歌搜索了一下,发现有些游戏根本无法识别任何发送命令。

在放弃之前,我只是尝试了一个简单的映射:

#IfWinActive, AirMech
  XButton1::c

它确实奏效了。

是否预期没有发送命令有效,但后者有效?如果我想触发其他操作(例如,'c' 加上一个 MsgBox)怎么办?

4

1 回答 1

1

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?)可能很重要。

映射中的星号表示“即使按下了额外的修饰符,也要触发热键”。

于 2013-04-24T18:58:06.983 回答