问题描述:
想把ins键变成翻译键:按一次为DeepL翻译,两次为搜狗翻译,
3个指令单独都能用放一起组合能生效单只能用一次是什么问题?想请教一下大神
以下是我的命令:
Ins::
if Ins_presses > 0 ; SetTimer 已经启动, 所以我们记录键击.
{
Ins_presses += 1
return
}
; 否则, 这是新开始系列中的首次按下. 把次数设为 1 并启动
; 计时器:
Ins_presses = 1
SetTimer, KeyIns, 400 ; 在 400 毫秒内等待更多的键击.
return
KeyIns:
SetTimer, KeyIns, off
if Ins_presses = 1 ; 此键按下了一次.
{
send,^c
Loop
{
StringReplace, clipboard,clipboard, `r`n,%A_SPACE%, UseErrorLevel
if ErrorLevel = 0 ;全部替换完,退出循环
break
}
Loop
{
StringReplace, clipboard,clipboard, %A_SPACE%%A_SPACE%, %A_SPACE%, UseErrorLevel;替换两个空格为一个空格
if ErrorLevel = 0
break
}
IfWinExist, DeepL翻译
{
WinActivate, DeepL翻译
IfWinActive, DeepL翻译
{
send,^w
}
}
str = %clipboard%
stringreplace, out, str, ` , `%20, All
DeepL = https://www.deepl.com/translator#en/zh/
URL = %DeepL%%out%
run,%URL%
return
}
else if Ins_presses = 2 ; 此键按下了两次.
{
send,^c
Loop
{
StringReplace, clipboard,clipboard, `r`n,%A_SPACE%, UseErrorLevel
if ErrorLevel = 0 ;全部替换完,退出循环
break
}
Loop
{
StringReplace, clipboard,clipboard, %A_SPACE%%A_SPACE%, %A_SPACE%, UseErrorLevel;替换两个空格为一个空格
if ErrorLevel = 0
break
}
IfWinExist, 搜狗翻译
{
WinActivate, 搜狗翻译
IfWinActive, 搜狗翻译
{
send,^w
}
}
str = %clipboard%
stringreplace, out, str, ` , `%20, All
sougou = https://fanyi.sogou.com/?keyword=
URL = %sougou%%out%
run,%URL%
return
}
; 不论触发了上面的哪个动作, 都对 count 进行重置
; 为下一个系列的按下做准备:
Ins_presses = 0
return
想把ins键变成翻译键:按一次为DeepL翻译,两次为搜狗翻译,
3个指令单独都能用放一起组合能生效单只能用一次是什么问题?想请教一下大神
以下是我的命令:
Ins::
if Ins_presses > 0 ; SetTimer 已经启动, 所以我们记录键击.
{
Ins_presses += 1
return
}
; 否则, 这是新开始系列中的首次按下. 把次数设为 1 并启动
; 计时器:
Ins_presses = 1
SetTimer, KeyIns, 400 ; 在 400 毫秒内等待更多的键击.
return
KeyIns:
SetTimer, KeyIns, off
if Ins_presses = 1 ; 此键按下了一次.
{
send,^c
Loop
{
StringReplace, clipboard,clipboard, `r`n,%A_SPACE%, UseErrorLevel
if ErrorLevel = 0 ;全部替换完,退出循环
break
}
Loop
{
StringReplace, clipboard,clipboard, %A_SPACE%%A_SPACE%, %A_SPACE%, UseErrorLevel;替换两个空格为一个空格
if ErrorLevel = 0
break
}
IfWinExist, DeepL翻译
{
WinActivate, DeepL翻译
IfWinActive, DeepL翻译
{
send,^w
}
}
str = %clipboard%
stringreplace, out, str, ` , `%20, All
DeepL = https://www.deepl.com/translator#en/zh/
URL = %DeepL%%out%
run,%URL%
return
}
else if Ins_presses = 2 ; 此键按下了两次.
{
send,^c
Loop
{
StringReplace, clipboard,clipboard, `r`n,%A_SPACE%, UseErrorLevel
if ErrorLevel = 0 ;全部替换完,退出循环
break
}
Loop
{
StringReplace, clipboard,clipboard, %A_SPACE%%A_SPACE%, %A_SPACE%, UseErrorLevel;替换两个空格为一个空格
if ErrorLevel = 0
break
}
IfWinExist, 搜狗翻译
{
WinActivate, 搜狗翻译
IfWinActive, 搜狗翻译
{
send,^w
}
}
str = %clipboard%
stringreplace, out, str, ` , `%20, All
sougou = https://fanyi.sogou.com/?keyword=
URL = %sougou%%out%
run,%URL%
return
}
; 不论触发了上面的哪个动作, 都对 count 进行重置
; 为下一个系列的按下做准备:
Ins_presses = 0
return