手把手教你按键精灵模糊查找句柄插件制作
- 格式:doc
- 大小:33.50 KB
- 文档页数:3
QQ群256416207
作者:【机器猫】
欢迎进群交流,转载请著名来源
VB制作模糊查找句柄的插件
在类模块中插入以下代码:
'这是第一个插件函数,返回一个字符串
'Public Function Test1() As String
' Test1 = "Hello, world"
'End Function
Public Function GetWindowsHwnd(s As String) As Long
Translate.str = s
Call EnumWindows(AddressOf Translate.EnumWndProc, 0&)
GetWindowsHwnd = Translate.hWnd
End Function
在模块头插入以下代码:复制黏贴就可以了
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As
Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd
As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public hWnd As Long
Public str As String
Public Function EnumWndProc(ByVal lhWnd As Long, ByVal lParam As Long) As Long
'EnumWindows 遍历窗口的回调函数
Dim Title1 As String * 255
'处理前窗口标题
Dim Title2 As String
'处理后窗口标题
Call GetWindowText(lhWnd, Title1, 255&)
'获取窗口标题
If (InStr(Title1, str) > 0&) Then
Title2 = Left(Title1, InStr(Title1, Chr(0&)) - 1&) '处理空
白字符
If Len(Title2) > 0 Then
'处理空字符
'Debug.Print lhWnd
Translate.hWnd = lhWnd
End If
End If
EnumWndProc = True
'继续下一个
End Function
然后生成插件就可以放到打开按键精灵
写入以下代码:运行看看效果
a=Plugin.Mcat.GetWindowsHwnd ("记事本")
If a = 0 Then
MessageBox "窗口不存在"
ExitScript
Else
MessageBox "窗口句柄为:"&a
End If