AutoHotKey 字符串替换

AutoHotKey String substitution

我正在编写一个小的 AHK 脚本,它定义了一些简单的 HotStrings。

概念是当我键入“Build QA1”时,会出现与该 HotString 关联的适当文本。

没问题...很简单...问题是我希望与 HotString 关联的字符串作为替换文本的一部分出现...在下面的示例中,结果应该是

构建 QA1
现在是所有好男人的时代

下面的脚本完成了这个并且工作正常......它完全我问的,HOWEVER,当我输入 HotString 文本并按 Enter 或 Tab 或任何启动 HotString 的方式时,第一行文本 (Build QA1) 将在屏幕上“闪烁”,因为它正在被替换……这很明显正在运行 HotString 替换 ...

理想情况下,我希望 HotString (Build QA1) 保留为 在不替换文本的情况下替换文本...这可能吗?或者有没有办法避免在替换该字符串时出现“闪烁”?

::构建 QA1::
发送,构建 QA1
发送,{enter}

发送,现在是所有好男人的时间
return

这样试试:

::b0::Build QA1::         ; automatic backspacing is not done to erase the abbreviation you type. 
ClipSaved := ClipboardAll ; save the entire clipboard to the variable ClipSaved
clipboard := ""           ; empty the clipboard (start off empty to allow ClipWait to detect when the new text has arrived
clipboard =               ; copy this text:
(
Now is the time for all good men
)
ClipWait, 1              ; wait for the clipboard to contain data. 
if (!ErrorLevel)         ; if NOT ErrorLevel ClipWait found data on the clipboard  
Send ^v                  ; paste the text
Sleep, 300               ; don't change clipboard while pasting! (Sleep > 0)
clipboard := ClipSaved   ; restore original clipboard
VarSetCapacity(ClipSaved, 0) ; free  the memory of the variable ClipSaved
return

请参阅文档中的 Hotstrings Options, Clipboard and ClipboardAll