使用匹配列表的Autohotkey动态热字符串

时间:2014-09-22 10:31:35

标签: dynamic replace autohotkey

我有以下问题:我有一个逗号分隔的文本值列表(它是歌曲名称和其他内容的列表)。现在我希望我的脚本跟踪我键入的内容,作为一般的热字符串脚本,当它匹配任何值时,它将用以下内容替换找到的匹配:[i]%match%[/ i] 使用的列表只是一个显示一般"形式"的所有可能性的例子。这些名字。

Songlist = "abc def,ghijk,lmn,, op,qrs (tuvw)"

:?*:%A_Space%::
{
Input, SongName, V*, {Space}.,{Enter}, %Songlist%
if ErrorLevel = Match
{
StringLen,songlength, songname
SendInput {BackSpace %SongLength%}[i]%Songname%[/i]
return
}
}

通常情况下,我可以解决问题,但是我无法理解这一点!

1 个答案:

答案 0 :(得分:0)

我总是使用数组而不是逗号分隔列表 您还需要动态热字串,幸运的是有一个很好的图书馆可以为您解决这个问题:
http://www.autohotkey.com/board/topic/98728-dynamic-hotstrings/ 要获取库,请在主脚本的文件夹中创建一个新的ahk脚本,将其命名为Hotstring.ahk并将代码粘贴+保存到其中:https://raw.githubusercontent.com/Menixator/ahk-repo/master/Hotstring/Hotstring.ahk 然后试试这个:

#include Hotstring.ahk
match = I Will Replace The Song Names
myList := ["abc def", "ghijk", "lmn", "op", "qrs (tuvw)"] ;create our list as array
Loop % myList.GetGaxIndex() { ;Loop through our array
    Hotstring(myList[A_Index],match) ;replace the song name with the contents of match when it's typed
}

如果这不是您想要的,请更具体地告诉我们您的需求 对我来说,it shall replace the found match with the following: [i]%match%[/i]的意思并不清楚。