【问题标题】:autohotkey text replacement with variable用变量替换自动热键文本
【发布时间】:2020-03-20 06:36:54
【问题描述】:

如果可能的话,我正在尝试找出一种用变量替换文本的方法。

基本上假设我有一个字符串:The Color is Red

我可以说::color::The Color is Red 会起作用,但现在如果我希望能够按需指定颜色怎么办。所以如果我输入color blue,它会打印出The Color is Blue

有没有办法做到这一点?或者我是否必须在我的脚本中定义我的句子的所有可能变体。

【问题讨论】:

    标签: autohotkey


    【解决方案1】:

    您可以使用 parsing Loop(或数组中的 For 循环)和 Hotstring() function 动态创建热字串:

    colors := "Blue,Red,White"
    Loop, parse, colors, `,
    Hotstring(":*:" "color " A_Loopfield, "The Color is "  A_Loopfield, On)
    

    以上代码必须放在auto-execute section(脚本顶部,在第一个热键、热字串或返回之前),否则脚本无法创建热字串。

    【讨论】:

    • 不是您要找的答案?
    猜你喜欢
    • 2017-07-07
    • 2021-12-21
    • 1970-01-01
    • 2023-03-26
    • 2010-12-26
    • 1970-01-01
    • 2013-03-20
    • 2019-02-06
    • 2018-11-19
    相关资源
    最近更新 更多