| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2618 人关注过本帖
标题:一个关于SendMessage的问题,大家给我看看这里出了什么问题[已解决,源码14楼 ...
取消只看楼主 加入收藏
俺老虎
Rank: 1
等 级:新手上路
帖 子:78
专家分:0
注 册:2005-9-15
收藏
 问题点数:0 回复次数:6 
一个关于SendMessage的问题,大家给我看看这里出了什么问题[已解决,源码14楼见]

Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) 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 SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
'Private Const WM_GETTEXT = &H7D
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE


Private Sub Form_Load()
Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()
On Error Resume Next
Dim sText As String * 255
Dim TextObj As Long
Dim txtLendth As Long, txtBuff As String

TheWindow = GetForegroundWindow '获得当前窗口句柄

If TheWindow = 0 Then Exit Sub
TheWindow_Title = Left$(sText, GetWindowText(TheWindow, sText, 255)) '得到聊天窗口标题~

If InStr(TheWindow_Title, "聊天中") = 0 Then
Exit Sub
Else
TextObj = FindWindowEx(TheWindow, 0, "#32770", vbNullString) '通用对话框的类
If TextObj = 0 Then Exit Sub
TextObj = FindWindowEx(TextObj, 0, "RichEdit20A", vbNullString) '聊天框的类
If TextObj = 0 Then Exit Sub
Text1.Text = SendMessage(TextObj, WM_GETTEXT, 0, 0)
End If

End Sub

打开QQ,进行聊天模式,和网友聊天,程序自动获得聊天记录,但是...前面都正确了,但是就是得不到内容...急了...大家帮帮忙啊~~~~~

[此贴子已经被作者于2006-11-17 18:23:14编辑过]

搜索更多相关主题的帖子: SendMessage 源码 
2006-11-12 22:47
俺老虎
Rank: 1
等 级:新手上路
帖 子:78
专家分:0
注 册:2005-9-15
收藏
得分:0 
指点一下啊..谢谢了~

http://www. 爱博客 只要一分钟,建立你自己的博客网站 完全免费哦~
2006-11-13 14:27
俺老虎
Rank: 1
等 级:新手上路
帖 子:78
专家分:0
注 册:2005-9-15
收藏
得分:0 
我确实是判断当前窗口是否为聊天窗口..如果是,才找通用对话框,以及聊天内容框的句柄....

如果不是,就退出过程啊....

哎..现在也不知道怎么办了~

http://www. 爱博客 只要一分钟,建立你自己的博客网站 完全免费哦~
2006-11-13 16:23
俺老虎
Rank: 1
等 级:新手上路
帖 子:78
专家分:0
注 册:2005-9-15
收藏
得分:0 
TextObj = FindWindowEx(TextObj, 0, "RichEdit20A", vbNullString) '聊天框的类
If TextObj = 0 Then Exit Sub

运行程序,打开一个聊天窗口,这一步通过...TextObj=0 为False

http://www. 爱博客 只要一分钟,建立你自己的博客网站 完全免费哦~
2006-11-13 16:25
俺老虎
Rank: 1
等 级:新手上路
帖 子:78
专家分:0
注 册:2005-9-15
收藏
得分:0 
继续求助~~~

http://www. 爱博客 只要一分钟,建立你自己的博客网站 完全免费哦~
2006-11-16 13:21
俺老虎
Rank: 1
等 级:新手上路
帖 子:78
专家分:0
注 册:2005-9-15
收藏
得分:0 
5555~~~flyly 提供一下思路如何....越说越急人了~

http://www. 爱博客 只要一分钟,建立你自己的博客网站 完全免费哦~
2006-11-16 13:58
俺老虎
Rank: 1
等 级:新手上路
帖 子:78
专家分:0
注 册:2005-9-15
收藏
得分:0 

谢谢..13楼的兄弟....

现在能成功得到了...我将源码全部发出来.....人人为我,我为人人!

Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) 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 SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
'Private Const WM_GETTEXT = &H7D
Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE

Private Sub Form_Load()
Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()
On Error Resume Next
Dim sText As String * 255
Dim TextObj As Long
Dim txtLendth As Long, txtBuff As String

TheWindow = GetForegroundWindow '获得当前窗口句柄

If TheWindow = 0 Then Exit Sub
thewindow_title = Left$(sText, GetWindowText(TheWindow, sText, 255)) '得到聊天窗口标题~
chatobj = thewindow_title

'Debug.Print thewindow_title

If InStr(thewindow_title, "聊天中") <> 0 Or InStr(thewindow_title, "- 群") <> 0 Or InStr(thewindow_title, "查看消息") <> 0 Then
TextObj = FindWindowEx(TheWindow, 0, "#32770", vbNullString) '通用对话框的类
If TextObj = 0 Then Exit Sub
TextObj = FindWindowEx(TextObj, 0, "RichEdit20A", vbNullString) '聊天框的类
If TextObj = 0 Then Exit Sub
txtLength = SendMessage(TextObj, WM_GETTEXTLENGTH, ByVal CLng(0), ByVal CLng(0))
txtBuff = Space(txtLength)
retVal = SendMessage(TextObj, 13, ByVal txtLength + 1, ByVal txtBuff)
Text1 = Left(txtBuff, retVal) & vbCrLf & vbCrLf & "以上聊天对象为:" & chatobj
Else
Exit Sub
End If

End Sub


http://www. 爱博客 只要一分钟,建立你自己的博客网站 完全免费哦~
2006-11-17 18:17
快速回复:一个关于SendMessage的问题,大家给我看看这里出了什么问题[已解决,源码 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012193 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved