按键精灵正则和窗口句柄

Function regex(txt, key)
'Maths 集合返回使用 vbCrLf 分隔;
'SubMatches 子集合返回使用 " " 分隔;
'& vbCrLf 添加回车
Dim rRet, Match, Matchs, rrRets, I
Set rExp = New RegExp '这里的 rExp 不可先被定义 否则下面一句会出错无效
Execute "rExp.Global = True"
rExp.IgnoreCase = False
rExp.Pattern = key
Set Matchs = rExp.Execute(txt)
rRet = ""
If Matchs.Count > 0 Then
For Each Match In Matchs
If Match.SubMatches.Count > 0 Then
rrRets = ""
For I = 0 To Match.SubMatches.Count - 1
If rrRets = "" Then
rrRets = Match.SubMatches(I)
Else
rrRets = rrRets & " " & Match.SubMatches(I)
End If
Next
If rRet = "" Then
rRet = rrRets
Else
rRet = rRet & vbCrLf & rrRets
End If
Else
If rRet = "" Then
rRet = Match
Else
rRet = rRet & vbCrLf & Match
End If
End If
Next
End If
Set rExp = Nothing
regex = rRet
End Function

'拿到窗口第一句柄
Function win(key)
HwndEx = Plugin.Window.Search(key)
m = Split(HwndEx, "|")
win = m(0)
End Function

'ctrl+"key"快捷键
Sub Ctrl(key)
KeyDown 17, 1
KeyPress key, 1
KeyUp 17, 1
End Sub

相关主题
相关文档
最新文档