问题

问题

UPDATED-STATEMENT: 20181102@112800@SUN Post created UPDATED-STATEMENT: 20181104@133200@TUE Suggested pre-requisite code that worked only for a short while UPDATED-STATEMENT: 20190101@184318@TUE Pre-requisite code no longer works in csgo anymore and never had with kf2 so I need help with another solution as to why it doesn't work perhaps an update happened preventing it from working for csgo

win10_v1803.17134.345_home
autohotkeyahk_v1.1.30.00

如何按住 w使用 AutoHotKey 按住 Logitech G502 上的 XButton1 时?问题是,当使用下面的脚本按住该键时,它只会发送一个输出,而不会产生真正的按住它的典型 Windows 行为(例如见下文)。请记住,这只是因为我有意使用它来玩 fps 游戏,但全局重新映射它比将我碰巧玩的每个游戏都作为更改 LogitechG502 控制按钮的一部分要容易得多。

我认为在游戏中一边用另一只手抓着热腾腾的奇多,一边向前走很酷

这里的建议会让游戏发生改变吗?

游戏是否越来越依赖于了解用户的按键操作?

问题

  • 我没有办法重新映射XButton1我的罗技G502复制持有w
    • ahk-while 命令可以工作,但行为不正确,即使在使用 ahk-sleep 减慢速度时,其速度也非常快,就像按下-释放-按下-释放一样
    • 请参阅下面的解决方案,设置几个 ahk 命令以将 LogitechG502 的 XButton1 重新映射到 w,以便在游戏中向前移动

解决方案

  • 至今无
    • 用户 3419297 建议的代码在与此帖子相关的 csgo 更新后不再有效

样本

  • 不工作:XButton1::SendInput, w ; mouse advanced button back as holding forward in-game
    • 保持3秒,X按钮1使用上面的脚本) 给我:w
    • 保持3秒,给我:wwwwwwwwwwwwwwwwwwwwwwwwww
  • 有效但不正确使用切换 (或快速重复按下 W):
    • 无法w正确复制持有,因为即使被 ahk-sleep 减慢速度,这种方法的重复速度也更快
$X按钮1::
       当 GetKeyState("XButton1", "P")
       发送
       返回
  • 工作不再
    • 这个先决条件代码在使用 2 个月后不再起作用,这可能是由于 csgo 更新,因为我没有另一个 fps 射击游戏来测试它
#无环境
#单例强制
#安装KeybdHook
#安装MouseHook
#使用Hook
#如果 WinActive ahk_exe csgo.exe || WinActive ahk_exe game2.exe || WinActive ahk_exe game3.exe
    X按钮1::w
#IfWinActive

答案1

这应该有效:

; maximum number of hotkeys that can be pressed within 2 seconds (default rate of hotkey activations)
; without triggering a warning dialog:
#MaxHotkeysPerInterval 10000

$XButton1::
while GetKeyState("XButton1", "P")
{
    Send w
    Sleep 20 ; ms or more if you  want to reduce the frequency of the send command 
}
return

未经测试。

https://autohotkey.com/docs/commands/While.htm

https://autohotkey.com/docs/commands/_MaxHotkeysPerInterval.htm

答案2

也可以尝试重新映射

#NoEnv
#SingleInstance Force
#InstallKeybdHook
#InstallMouseHook
#UseHook

#IfWinActive Title of my game

    XButton1::w

#IfWinActive

将其替换Title of my game为 Window Spy 中显示的游戏窗口的确切标题。

https://autohotkey.com/docs/commands/_IfWinActive.htm

编辑:

您可以使用 #If- 或 #IfWinActive- 指令为多个应用程序/窗口创建上下文相关热键:

#If WinActive("Title of my game1") || WinActive("Title of my game2") ; "||" means "OR"

    XButton1::w
    XButton2::x

#If WinActive("Title of my game3")  

    XButton1::a
    XButton2::b

#If  ; turn off context sensitivity

; In all other applications/windows you can make XButton1 and XButton2 to do something else, e.g.:

XButton1:: Send ^c  ; copy
XButton2:: Send ^v  ; paste

https://autohotkey.com/docs/commands/_If.htm

答案3

XButton1::
;ToolTip, XButton1 down
SendInput {w down}
Return

XButton1 Up::
SendInput {w up}
;ToolTip, XButton1 up
Return

-“XButton1::”行指定了 XButton1 的热键,XButton1 是鼠标上的一个侧键。这意味着按下 XButton1 时,将运行以下行,直到 Return。-“SendInput {w down}”行导致发送“w down”事件,满足 OP 按下按键的请求(首先发送 aw down 事件),而如果您只是按下“SendInput w”,则不会发送相应的 keyup 事件。使用“down”,按键将一直保持,直到发送“up”。-“Return”行结束 XButton1 的热键。

-“XButton1 Up::”行指定了当 Xbutton 被释放(向上)时触发的热键。-“SendInput {w up}”行发送 w 键的向上事件。由于此事件与“XButton1 up”热键相关联,因此这意味着该热键满足了 OP 使用鼠标按钮按住另一个键的请求。-“Return”行结束了“XButton1 up”热键。+“;ToolTip”行是注释,我可以删除它们,但取消注释它们并查看在按下和释放 Xbutton1 时触发工具提示会很有用。

您可以将“XButton1”和“w”标记更改为不同的键以实现所需的效果。

相关内容