全匹配和模糊匹配查找句柄

标题全匹配情况下查找窗口句柄

Hwnd = Plugin.Window.Find(0, "东觉的浏览器")

MessageBox Hwnd

//以下内容供测试用

Call Plugin.Window.Hide(Hwnd)

Plugin.Msg.Tips ("1")

Delay 300

Call Plugin.Window.Active(Hwnd)

Plugin.Msg.Tips ("2")

Delay 300

Call Plugin.Window.Show(Hwnd)

Plugin.Msg.Tips ("3")

Delay 300

Call Plugin.Window.Top(Hwnd, 0)

Plugin.Msg.Tips ("4")

Delay 300

Call Plugin.Window.Top(Hwnd, 1)

Plugin.Msg.Tips ("5")

模糊标题的情况下查找句柄

//下面这句是按查找方式(模糊),遍历符合窗口类名(0)且标题("记事本")的句柄,保存到数组(HwndEx)里

HwndEx = Plugin.Window.SearchEx(0,"健邑",0)

MsgBox "查找到符合的窗口句柄为:" & HwndEx

//下面这句用于分割字符串,将获得的句柄组分割

dim MyArray

MyArray = Split(HwndEx, "|")

If UBound(MyArray)>=0 Then

i=0

For UBound(MyArray)

//下面这句将字符串转换成数值

Msgbox "第 " & i + 1 & " 个窗口句柄为:" & Clng(MyArray(i))

Hwnd = Clng(MyArray(i))

Plugin.Msg.Tips (Hwnd)

//以下内容供测试用

Call Plugin.Window.Hide(Hwnd)

Plugin.Msg.Tips ("1")

Delay 300

Call Plugin.Window.Active(Hwnd)

Plugin.Msg.Tips ("2")

Delay 300

Call Plugin.Window.Show(Hwnd)

Plugin.Msg.Tips ("3")

Delay 300

Call Plugin.Window.Top(Hwnd, 0)

Plugin.Msg.Tips ("4")

Delay 300

Call Plugin.Window.Top(Hwnd, 1)

Plugin.Msg.Tips ("5")

Delay 3000

i=i+1

Next

End If

(Tips:在里缩进很麻烦,在粘贴到按键精灵的时候用一下自动缩进功能即可)

你可能感兴趣的:(全匹配和模糊匹配查找句柄)