为了获取qq聊天信息与自动发送,笔者完成CQQChatWnd类,首先贴出类的内容,然后讲述用法1.头文件QQChatWnd.h// QQChatWnd.h: interface for the CQQChatWnd class.
#if !defined(QQCHATWND_H)
#define QQCHATWND_H#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define MSG_CHAT_MODE 1
#define P2P_CHAT_MODE 2
class CQQChatWnd  
{
public:
bool Chat( void );
bool AddChatText(char *lpstrText);
bool SetChatText( char * lpstrText );
bool GetChatText(char **lplpstrText/*out*/) ;
bool ChangeSysMode( int nSysMode );
int  GetSysMode( void );
bool Detach( HWND hChatWnd);
bool Attatch(HWND  hChatWnd);public:
CQQChatWnd();
virtual ~CQQChatWnd();private:
static BOOL  CALLBACK SearchSysModeEnumProc(HWND hwnd,  LPARAM lParam);
static BOOL  CALLBACK SearchSendButtonEnumProc(HWND hwnd,  LPARAM lParam);
static BOOL  CALLBACK SearchRichEditEnumProc( HWND hwnd , LPARAM lParam );
bool GetChatRichEditWnd( HWND *pChatRichEditWnd /*in,out*/);
bool GetChatToolbarWnd( HWND *pChatToolbarWnd /*in,out*/);
bool GetSendButtonWnd( HWND *pSendButtonWnd /*in,out*/);
bool GetModeWnd( HWND *pModeWnd /*in,out*/);
int m_nSysMode;
HWND m_hChatWnd;
HWND m_hChatToolbarWnd;
HWND m_hSendButtonWnd;
HWND m_hModeWnd;
HWND m_hChatRichEditWnd;
};#endif

解决方案 »

  1.   

    3.类对外接口说明 
    bool Attatch(HWND  hChatWnd); //初始化类,把hChatWnd聊天窗口同类连接
    bool Detach( HWND hChatWnd);//解除类与hChatWnd的绑定
    bool GetChatText(char **lplpstrText/*out*/) ;//获取聊天内容,内容存放
                                                 //在*lplpstrText
    bool SetChatText( char * lpstrText );//设置聊天内容
    bool AddChatText(char *lpstrText);//增加聊天内容
    bool Chat( void );//聊天动作,模拟点击发送按钮
    int  GetSysMode( void );//获取聊天模式
    bool ChangeSysMode( int nSysMode );//改变聊天模式4.用法#include "QQChatWnd.h"HWND  hwnd = (HWND )0x000B048A ; //qq聊天窗口句柄
    CQQChatWnd  qqchatwin ;
    qqchatwin.Attatch( hwnd ) ;char * lpstrText = NULL ; //必须的qqchatwin.GetChatText( &lpstrText ) ;delete [] lpstrText ; //数据,否则内存泄露int nSysMode = qqchatwin.GetSysMode() ;qqchatwin.ChangeSysMode( P2P_CHAT_MODE ) ;qqchatwin.SetChatText( "hello, dear ") ;
    qqchatwin.AddChatText( "hello, dear ") ;qqchatwin.Chat() ;qqchatwin.Detach( hwnd ) ;
      

  2.   

    2.类的实现文件见
    http://community.csdn.net/Expert/topic/5295/5295300.xml?temp=.1082422