为什么"密钥等待在Autohotkey中会导致在键入时替换两个字母? [英] Why " Keywait " in Autohotkey cause two letters be replaced during typing?
问题描述
我有这个脚本:
#IfWinActive Oxford Advanced Learner's Dictionary
$m::
KeyWait,m,T0.25
If (ErrorLevel)
{
Click, 210,563, 10
sleep,100
Send, {Down}
KeyWait,m
}
Else
{
Send, m
}
return
$i::
KeyWait, i, T0.25
If (ErrorLevel) {
Loop 7
Click, 768,192,3
} else {
Send, i
}
return
但是当我快速输入字母 m 和 i 时,会键入"&它键入即时通讯反而.但是当我键入较慢时,不会出现任何问题.为什么会发生这种情况以及如何解决此问题?
But when I type the letters m and i fast to type " mi " it types " im " instead. but when I type them slower, no problem occurs. why this happens and How can I fix this issue?
推荐答案
I think this quote from the Threads page is relevant here:
尽管AutoHotkey实际上并没有使用多个线程,但是它模拟了某些行为:如果启动了第二个线程-例如在前一个线程仍在运行时通过按下另一个热键-当前线程将被中断(临时暂停)以允许新线程成为当前线程.如果在第二个线程仍在运行时启动了第三个线程,则第二个线程和第一个线程都将处于休眠状态,依此类推.
Although AutoHotkey doesn't actually use multiple threads, it simulates some of that behavior: If a second thread is started -- such as by pressing another hotkey while the previous is still running -- the current thread will be interrupted (temporarily halted) to allow the new thread to become current. If a third thread is started while the second is still running, both the second and first will be in a dormant state, and so on.
当前线程结束时,最近中断的那个线程将恢复,依此类推,直到所有线程最终完成.
When the current thread finishes, the one most recently interrupted will be resumed, and so on, until all the threads finally finish.
我相信,当您在m之后输入i时,如果m键等待仍在超时范围之内,它会迅速暂停该键等待并运行i.
I believe when you type i after m, in a quick manner while the m keywait is still inside the timeout, it pauses that keywait and runs i's.
关于如何解决此问题的方法,只需在m中添加关键热键,请注意,这将使其完成,因此在此操作完成之前不会再运行其他热键,但是它将使所有操作排队:
As to how to fix this, merely add Critical in the m hotkey, note this will make it so no other hotkey will run before this one is done, it will however queue things up:
#IfWinActive Oxford Advanced Learner's Dictionary
$m::
Critical
KeyWait,m,T0.25
If (ErrorLevel)
{
Click, 210,563, 10
sleep,100
Send, {Down}
KeyWait,m
} else {
Send, m
}
return
$i::
KeyWait, i, T0.25
If (ErrorLevel) {
Loop 7
Click, 768,192,3
} else {
Send, i
}
return
这篇关于为什么"密钥等待在Autohotkey中会导致在键入时替换两个字母?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!