Autohotkey脚本在点击时发送空间并在保持时移位。它正在影响其他映射

时间:2016-08-30 10:51:07

标签: autohotkey

我编写了这个脚本,让我的空格键在点击时充当空格键,并在按住时用作换档按钮。但是,它会影响映射,例如

  

:: btw ::顺便说一下

情景:

当我输入“btw”将“btw”转换为“顺便说一句”后点击空格键时,转换没有发生。

无论如何我可以在下面更改我的脚本以确保在上述情况下进行转换吗?

$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

谢谢:)

3 个答案:

答案 0 :(得分:0)

Hotstrings忽略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

答案 1 :(得分:0)

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

:*:btw::by the way

而不是

::btw::by the way

即使您有btw提到的热键

,也会自动将by the way替换为space

答案 2 :(得分:0)

@Neo Ding Yue工作正常吗?最初,我像您一样做到了,但是它有很多缺陷。终于,我找到了两年以来一直在使用的解决方案:1.注册表重映射空间的行为类似于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

如果您有问题,请问(我有其他版本)。