如何在Autohotkey中通过RegExp匹配包含键名的字符串
我正在尝试从文本文件加载字母数字击键,并通过AHK重播它们。文本文件中嵌入了键名,例如{up} 对于任何字母数字行,我都要发送一个{enter}。但是对于嵌入的键名,我想跳过{enter} 下面是Macro.txt:如何在Autohotkey中通过RegExp匹配包含键名的字符串,autohotkey,Autohotkey,我正在尝试从文本文件加载字母数字击键,并通过AHK重播它们。文本文件中嵌入了键名,例如{up} 对于任何字母数字行,我都要发送一个{enter}。但是对于嵌入的键名,我想跳过{enter} 下面是Macro.txt: 1 2 3 4 5 Hello World {up}{up} 为了检测{up}{up}键名,我尝试使用RegExpMatch iskey := RegExMatch(%a_loopReadLine%, "giA)(\{\w+\})") 但是当AHK获取{up}{up}
1
2
3
4
5
Hello World
{up}{up}
为了检测{up}{up}键名,我尝试使用RegExpMatch
iskey := RegExMatch(%a_loopReadLine%, "giA)(\{\w+\})")
但是当AHK获取{up}{up}内容时,它会抛出一个错误:
错误:以下变量名包含非法字符:“{up}{up}”
我也尝试了IfInStr
。但不知怎么的,我一直坚持在字符串中嵌入键名
'''
'将RegExMatch(%a\u loopReadLine%,giA)(\{\w+\})更改为RegExMatch(a\u loopReadLine,giA)(\{\w+\})
。没有%%。
^r::
loop, read, Macro.txt
{
SendInput, %a_loopReadLine%
iskey := RegExMatch(%a_loopReadLine%, "giA)(\{\w+\})")
IfNotEqual, iskey, 0
{
SendInput, {enter}
}
}