使用自动热键为按键添加人为延迟 [英] Using Autohotkey to add an artificial delay to a keypress

查看:178
本文介绍了使用自动热键为按键添加人为延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用自动热键为按键添加人为延迟.我在一个设有机械键盘和台式麦克风的瓷砖房间中.我想在PTT键上增加大约1/10秒的人为延迟,以使其他人在按下该键时听不到咔嗒声.我最终将键绑定到其他数字键盘-"上,以便使Capslock成为我实际按下的键.这是我最终得到的脚本.

I am trying to use autohotkey to add an artificial delay to a keypress. I am in a tiled room, with a mechanical keyboard, and a desktop microphone. I would like to add an artificial delay of approximately 1/10 of a second to my PTT key, so that others don't hear the audible CLICK when I press the key. I ended up binding the key to something else "numpad -" so that capslock could be the key I actually press. This is the script I ended up with.

预期结果:按下capslock会延迟0.1s按下numpad-,然后按住该键,直到我释放capslock(释放时也应该解开capslock)

Expected result: pressing capslock presses numpad- on a 0.1s delay, and then holds the key until I release capslock(and it should also unpress capslock on release)

实际结果:它可以工作,但是如果我过快按下并释放它,它会按住小键盘-"并向下锁定,而不会释放它们.

Actual result: It works, but if I press and release it too quickly, it holds "numpad -" down and capslock down, and releases neither.

代码:

#UseHook

*~Capslock::
    sleep, 100 
    Send {NumpadSub Down}
    sleep, 100
    While GetKeyState("Capslock")
    {

    }
return

*~Capslock Up::
    sleep, 300
    Send {NumpadSub Up}
return

程序没有打开睡眠键,就打开了钥匙,关闭了钥匙,然后重新打开.

without the sleeps as is, the program opens the key, closes the key, and then re-opens.

推荐答案

UseHook

答案:

*~Capslock::
        sleep, 100 
        Send {NumpadSub Down}
        keyWait, Capslock, U
        sleep, 100
        Send {NumpadSub Up}
    return

这篇关于使用自动热键为按键添加人为延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆