|
遍历所有窗口,再查找下UC浏览器试试
- Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
- 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 Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
- Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
- Public oDic
- Const SW_SHOWMAXIMIZED = 3
- Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
- Dim oWK As Worksheet
- Set oWK = ActiveSheet
- Dim sCN As String
- Dim sTitle As String
- sCN = Space(1024)
- sTitle = Space(1024)
- Dim iLen1, iLen2
- iLen1 = GetClassName(hwnd, sCN, 1024)
- iLen2 = GetWindowText(hwnd, sTitle, 1024)
- sCN = Replace(Trim(Left(sCN, iLen1)), Chr(0), "")
- sTitle = Replace(Trim(Left(sTitle, iLen2)), Chr(0), "")
- With oWK
- sValue = sTitle & "!" & hwnd & "!" & sCN
- oDic.Add sValue, ""
- End With
- EnumWindowsProc = True
- End Function
- Sub FindTitle()
- Set oDic = CreateObject("Scripting.Dictionary")
- EnumWindows AddressOf EnumWindowsProc, 0
- arrKey = oDic.keys
- arr = Filter(arrKey, "UC浏览器!")
- For i = 0 To UBound(arr)
- sResult = arr(i)
- sTitle = Split(sResult, "!")(0)
- lHwnd = Split(sResult, "!")(1)
- sClassName = Split(sResult, "!")(2)
- Debug.Print sTitle
- Next
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|