Autohotkey 脚本在点击时发送 space 并在按住时移动。它正在影响其他映射

Autohotkey script to send space when tapped and shift when held. It is affecting other mappings

我编写此脚本是为了让我的 space-bar 按钮在点击时充当 space-bar,在按住时充当 shift 按钮。但是,它会影响

等映射

::btw::by the way

场景:

当我在输入 "btw" 后点击 space-bar 将 "btw" 转换为 "by the way " 时,转换没有发生。



我是否可以更改下面的脚本以确保在上述情况下发生转换?

$Space::
now := A_TickCount
while GetKeyState("Space", "P") ; to find out whether space-bar is held 
    if (A_TickCount-now > 180) ; this time is tested on asker's computer
    {
        SendInput {Shift Down}
        KeyWait, Space
        SendInput {Shift Up}
        return
    }
SendInput {Space} ; if key detected to be tapped, send space as per normal
return

谢谢:)

如果热字串的发送级别等于或低于事件的发送级别,则热字串将忽略 Autothotkey 生成的事件。

这意味着 Space 的发送级别必须设置为比您希望用它触发的主机级别更高的级别:

#InputLevel, 10  ;set send level for the following code to 10
$Space::
#InputLevel  ;set it back to default value of 0 for any remaining code
now := A_TickCount
while GetKeyState("Space", "P") ; to find out whether space-bar is held 
    if (A_TickCount-now > 180) ; this time is tested on asker's computer
    {
        SendInput {Shift Down}
        KeyWait, Space
        SendInput {Shift Up}
        return
    }

SendInput {Space} ; if key detected to be tapped, send space as per normal   
return

您必须将 btw 的自动替换代码更改为

:*:btw::by the way

而不是

::btw::by the way

这将自动将 btw 替换为 by the way,即使您有提到的 space

热键

@Neo Ding Yue 有效果吗?最初我像你一样做了,但它有很多缺陷。最后我找到了一个我使用了两年的解决方案: 1. 注册表重新映射 space 以表现得像 LShift 并使用此代码:

~*LShift::    ;tilde so it gets triggered already on down, in combination with any key, hence can be used as modifier key
Keywait,LShift, L ; just to deactivate autofire
return

~LShift up::
IF(A_TimeSincePriorHotkey < 150 && A_PriorKey = "LShift") {
    SendInput {Space}
}
return

有问题尽管问(我有其他版本)