Autohotkey-替换不同的单词或句子 [英] Autohotkey - Replace different words or sentences

查看:57
本文介绍了Autohotkey-替换不同的单词或句子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我使用的这个脚本中,我只能替换一个单词 teams -> 米兰,尤文图斯,国际米兰.但是我想替换许多单词(不仅是一个单词),例如:

in this script that I use i can replace only one word teams--> milan, juventus, inter.. But i want replace many words (not only one word) for example:

[简单单词替换插孔-> beta]

[simply word replacement jack-->beta]

alfa-->beta

[句子替换杰克-> jack,john,alfa ]

[sentence replacement jack-->jack,john,alfa]

jack

jack
john
alfa

这实际上是我使用的代码

This is actually code that i use

loop {
    While !RegexMatch(strCapture, "teams$") {
        Input, strUserInput, V L1, {BackSpace}  ; V: visible, L1: Character length 1
        If ErrorLevel = Endkey:BackSpace
            strCapture := SubStr(strCapture, 1, StrLen(strUserInput) - 1) 
        else
            strCapture .= strUserInput
        ; tooltip % ErrorLevel "`n" strUserInput "`n" strCapture "`n" ; enable this to see what actually happens
    }
    SendInput,
    (Ltrim
        {Backspace 5}
        milan
        juventus
        inter
        roma
        lazio
        napoli
        mantova
    )
    strCapture := ""
}

如何修改代码?
还可以运行集成了复制粘贴功能的脚本吗?

How can I modify the code?
It is also possible to run the script integrating copy-paste?

推荐答案

您可以使用For循环替换内容,但是要保持规模,YMMV将变得越来越乏味.

You could use a For loop to replace the contents, but this would become increasingly tedious to maintain at scale, so YMMV.

以下内容将剪贴板内容用作to/from变量,但是您可以根据需要将其替换为变量(用字符串变量替换"clipboard").

The following will use the clipboard contents as the to/from variables, but you can swap it out with a variable as desired (replace "clipboard" with your string variable).

F3::
{
    replace := {"alfa":"beta", "gamma":"delta"}
    For start, end in replace {
    StringReplace, clipboard, clipboard, %start%, %end%, All
}}
Return

这篇关于Autohotkey-替换不同的单词或句子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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