dim qqHwnd as long qqHwnd = findwindow (vbnullstring,"QQ登录窗口的名字")findwindow 返回的 qqHwnd 就是你要的句柄
FindWindow 使用的申明:Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Option Explicit Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As LongPrivate Sub Timer1_Timer() Dim qqlogin As Long qqlogin = FindWindow("#32770", vbNullString) If qqlogin Then Dim flag As Long flag = FindWindowEx(qqlogin, 0, "Static", "申请密码保护,确保号码安全") If flag Then Debug.Print "qq login window is run" End If End If End Sub
qqHwnd = findwindow (vbnullstring,"QQ登录窗口的名字")findwindow 返回的 qqHwnd 就是你要的句柄
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As LongPrivate Sub Timer1_Timer()
Dim qqlogin As Long
qqlogin = FindWindow("#32770", vbNullString)
If qqlogin Then
Dim flag As Long
flag = FindWindowEx(qqlogin, 0, "Static", "申请密码保护,确保号码安全")
If flag Then
Debug.Print "qq login window is run"
End If
End If
End Sub