所谓的设置标题和设置内容的区别,我有一堆程序,干什么都可以
Dim gHW As Long
Dim s As String
Dim sNum As LongPublic Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, lParam As Long) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
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 SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) 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 SendMessageVal Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long
Public Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function SendMessageByStr& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String)Public Const WM_GETTEXT = &HD
Public Const WM_SETTEXT = &HC
Public Const WM_CHAR = &H102'Public Function EnumChildProc(ByVal hWnd As Long, ByVal lParam As Long) As Long
'Public Function EnumChildProcC(ByVal hWnd As Long, ByVal lParam As Long) As Long
'Public Function EnumWindowProc(ByVal hWnd As Long, ByVal lParam As Long) As Long
'Public Function EFindChildByTitle(ByVal hWnd As Long, ByVal chldtxt As String, Optional parentHwnd = 0, Optional num As Integer = 1)
'Public Function EFindChildByClass(ByVal hWnd As Long, ByVal chldtxt As String, Optional parentHwnd = 0, Optional num As Integer = 1)
'Public Function EFindWindowByTitle(chldtxt As String)
'Public Function vbGetWindowClass(ahWnd As Long) As String
'Public Function vbSetWindowText(ahWnd As Long, strSetText As String) As Integer
'Public Function vbSendCharNum(Window As Long, Chars As Long) As LongPublic Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Static q As Integer
Dim x As String
x = vbGetWindowText(hwnd)
If lParam = 0 Then
'Debug.Print lparam
If LCase(x) Like LCase(s) And q = sNum Then
q = q + 1
If (q = sNum) Then
gHW = hwnd
EnumChildProc = False
q = 0
Exit Function
Else
EnumChildProc = True
Exit Function
End If
Else
EnumChildProc = True
Exit Function
End If
Else
If (LCase(x) Like LCase(s)) And _
(GetParent(hwnd) _
= lParam) Then
gHW = hwnd
EnumChildProc = False
q = 0
Exit Function
Else
EnumChildProc = True
Exit Function
End If
End If
End FunctionPublic Function EnumChildProcC(ByVal hwnd As Long, ByVal lParam As Long) As Long
Static q As Integer
Dim x As String
x = vbGetWindowClass(hwnd)
If lParam = 0 Then
'Debug.Print lparam
If LCase(x) Like LCase(s) Then
q = q + 1
If q = sNum Then
q = 0
gHW = hwnd
EnumChildProcC = False
Exit Function
Else
EnumChildProcC = True
Exit Function
End If
Else
EnumChildProcC = True
Exit Function
End If
Else
If (LCase(x) Like LCase(s)) And (GetParent(hwnd) = lParam) Then
q = q + 1
If (q = sNum) Then
gHW = hwnd
EnumChildProcC = False
q = 0
Exit Function
Else
EnumChildProcC = True
Exit Function
End If
Else
EnumChildProcC = True
Exit Function
End If
End If
End FunctionPublic Function EnumWindowProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim x As String
x = vbGetWindowText(hwnd)
If LCase(x) Like LCase(s) Then gHW = hwnd: EnumWindowProc = False: Exit _
Function
EnumWindowProc = True
Exit Function
End Function
Public Function EnumWindowProc1(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim y As String
Dim x As String
Dim i As Integer
y = String$(100, Chr(0))
GetClassName hwnd, y, 100
For i = 1 To 100
If Mid(y, i, 1) <> Chr(0) Then
x = x & Mid(y, i, 1)
Else
Exit For
End If
Next i
'x = Trim(x)
'Debug.Print x
If LCase(x) = LCase(s) Then gHW = hwnd: EnumWindowProc1 = False: Exit _
Function
EnumWindowProc1 = True
Exit Function
End Function
Dim gHW As Long
Dim s As String
Dim sNum As LongPublic Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, lParam As Long) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
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 SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) 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 SendMessageVal Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long
Public Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function SendMessageByStr& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String)Public Const WM_GETTEXT = &HD
Public Const WM_SETTEXT = &HC
Public Const WM_CHAR = &H102'Public Function EnumChildProc(ByVal hWnd As Long, ByVal lParam As Long) As Long
'Public Function EnumChildProcC(ByVal hWnd As Long, ByVal lParam As Long) As Long
'Public Function EnumWindowProc(ByVal hWnd As Long, ByVal lParam As Long) As Long
'Public Function EFindChildByTitle(ByVal hWnd As Long, ByVal chldtxt As String, Optional parentHwnd = 0, Optional num As Integer = 1)
'Public Function EFindChildByClass(ByVal hWnd As Long, ByVal chldtxt As String, Optional parentHwnd = 0, Optional num As Integer = 1)
'Public Function EFindWindowByTitle(chldtxt As String)
'Public Function vbGetWindowClass(ahWnd As Long) As String
'Public Function vbSetWindowText(ahWnd As Long, strSetText As String) As Integer
'Public Function vbSendCharNum(Window As Long, Chars As Long) As LongPublic Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Static q As Integer
Dim x As String
x = vbGetWindowText(hwnd)
If lParam = 0 Then
'Debug.Print lparam
If LCase(x) Like LCase(s) And q = sNum Then
q = q + 1
If (q = sNum) Then
gHW = hwnd
EnumChildProc = False
q = 0
Exit Function
Else
EnumChildProc = True
Exit Function
End If
Else
EnumChildProc = True
Exit Function
End If
Else
If (LCase(x) Like LCase(s)) And _
(GetParent(hwnd) _
= lParam) Then
gHW = hwnd
EnumChildProc = False
q = 0
Exit Function
Else
EnumChildProc = True
Exit Function
End If
End If
End FunctionPublic Function EnumChildProcC(ByVal hwnd As Long, ByVal lParam As Long) As Long
Static q As Integer
Dim x As String
x = vbGetWindowClass(hwnd)
If lParam = 0 Then
'Debug.Print lparam
If LCase(x) Like LCase(s) Then
q = q + 1
If q = sNum Then
q = 0
gHW = hwnd
EnumChildProcC = False
Exit Function
Else
EnumChildProcC = True
Exit Function
End If
Else
EnumChildProcC = True
Exit Function
End If
Else
If (LCase(x) Like LCase(s)) And (GetParent(hwnd) = lParam) Then
q = q + 1
If (q = sNum) Then
gHW = hwnd
EnumChildProcC = False
q = 0
Exit Function
Else
EnumChildProcC = True
Exit Function
End If
Else
EnumChildProcC = True
Exit Function
End If
End If
End FunctionPublic Function EnumWindowProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim x As String
x = vbGetWindowText(hwnd)
If LCase(x) Like LCase(s) Then gHW = hwnd: EnumWindowProc = False: Exit _
Function
EnumWindowProc = True
Exit Function
End Function
Public Function EnumWindowProc1(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim y As String
Dim x As String
Dim i As Integer
y = String$(100, Chr(0))
GetClassName hwnd, y, 100
For i = 1 To 100
If Mid(y, i, 1) <> Chr(0) Then
x = x & Mid(y, i, 1)
Else
Exit For
End If
Next i
'x = Trim(x)
'Debug.Print x
If LCase(x) = LCase(s) Then gHW = hwnd: EnumWindowProc1 = False: Exit _
Function
EnumWindowProc1 = True
Exit Function
End Function
If Right(chldtxt, 1) <> "*" Then chldtxt = chldtxt & "*"
sNum = num
If parentHwnd = 0 Then
s = chldtxt
EnumChildWindows hwnd, AddressOf EnumChildProc, 0
EFindChildByTitle = gHW
s = 0
gHW = 0
Else
s = chldtxt
EnumChildWindows hwnd, AddressOf EnumChildProc, parentHwnd
EFindChildByTitle = gHW
s = 0
gHW = 0
End If
End Function
Public Function EFindChildByClass(ByVal hwnd As Long, ByVal chldtxt As String, Optional parentHwnd = 0, Optional num As Integer = 1)
sNum = num
If parentHwnd = 0 Then
s = chldtxt
EnumChildWindows hwnd, AddressOf EnumChildProcC, 0
EFindChildByClass = gHW
s = 0
gHW = 0
Else
s = chldtxt
EnumChildWindows hwnd, AddressOf EnumChildProcC, parentHwnd
EFindChildByClass = gHW
s = 0
gHW = 0
End If
End FunctionPublic Function EFindWindowByTitle(chldtxt As String) As Long
s = chldtxt
EnumWindows AddressOf EnumWindowProc, 0
EFindWindowByTitle = gHW
gHW = 0
End Function
Public Function EFindWindowByClass(clstxt As String) As Long
s = clstxt
EnumWindows AddressOf EnumWindowProc1, 0
EFindWindowByClass = gHW
gHW = 0
End Function
Public Function vbGetWindowClass(ahWnd As Long) As String
Dim Ret As String
Dim i As Long
If ahWnd = 0 Then Exit Function
Ret = String$(80, 0)
i = GetClassName(ahWnd, Ret, 80)
vbGetWindowClass = Left$(Ret, i)End Function
Public Function vbGetWindowText(ahWnd As Long) As String
Dim c As Integer
Dim t As String
If ahWnd = 0 Then Exit Function
t = String(256, " ")
c = SendMessage(ahWnd, 14, 0&, 0&)
SendMessageByStr ahWnd, 13, c + 1, t
If InStr(t, Chr$(0)) Then
t = Left(t, InStr(t, Chr$(0)) - 1)
End If
If t = "" Then c = GetWindowText(ahWnd, t, 256)
vbGetWindowText = t
End FunctionPublic Function vbSetWindowText(ahWnd As Long, strSetText As String) As Integer
Dim t As String
Dim c As String
vbSetWindowText = SendMessageByStr(ahWnd, WM_SETTEXT, 0, strSetText)
End FunctionPublic Function vbSendCharNum(Window As Long, Chars As Long) As Long
Dim i As Long
i = 0
vbSendCharNum = SendMessageVal(Window, WM_CHAR, Chars, i)
End Function
'====================================================================
vbSetWindowText
vbGetWindowText
足以解决。
简介:
捕捉QQ窗体句柄,
捕捉QQ窗体上文本框控件的句柄 ,
向他发送信息,
向QQ的确定按钮发出鼠标点击的消息.
(惨了,做QQ发送消息炸弹了.)