qq尾巴例子.txt
上传用户:jiansibo
上传日期:2015-07-04
资源大小:524k
文件大小:2k
- {qq尾巴例子,2000毫秒发送一次}
- program QQtailer;
- uses
- Windows,
- Messages;
- var
- TimerHandle:WORD;
- MSG:TMSG;
- procedure TimerProc(Wnd:HWnd;Msg,TimerID,dwTime:DWORD);stdcall;
- var
- hLastWin,hButton : THandle;
- szWindowText: array[0..MAX_PATH] of Char;
- szTextLength: Integer;
- QQName:String;
- begin
- hLastWin := GetForegroundWindow;
- GetClassName(hLastWin,szWindowText,SizeOf(szWindowText));
- if szWindowText <>'#32770' then Exit;
- szTextLength := SendMessage(hLastWin, WM_GETTEXT, MAX_PATH, Integer(@szWindowText[0]));
- szWindowText[szTextLength] := #0;
- if Pos('聊天中',szWindowText)>0 then
- begin
- QQName:=Copy(szWindowText,Pos(' ',szWindowText)+1,Pos('聊天中',szWindowText)-Pos(' ',szWindowText)-2);
- hLastWin := FindWindowEx(hLastWin, THandle(nil),'#32770',nil);
- if hLastWin=0 then Exit;
- hButton := FindWindowEx(hLastWin, THandle(nil),nil,'发送(&S)');
- if hButton=0 then Exit;
- hLastWin := FindWindowEx(hLastWin, THandle(nil),'AfxWnd42',nil);
- if hLastWin=0 then Exit;
- hLastWin := FindWindowEx(hLastWin, THandle(nil),'RICHEDIT',nil);
- if hLastWin=0 then Exit;
- QQName:=QQName+'在吗?';
- SendMessage(hLastWin,EM_REPLACESEL,180,Integer(Pchar(QQName)));
- SendMessage(hButton, WM_LBUTTONDOWN, 0, 0);
- SendMessage(hButton, WM_LBUTTONUP, 0, 0);
- end;
- end;
- procedure StartTimer(Interval:DWORD);
- begin
- TimerHandle:=SetTimer(0,0,Interval,@TimerProc);
- end;
- begin
- StartTimer(2000);
- while(GetMessage(Msg,0,0,0))do
- begin
- TranslateMessage(Msg);
- DispatchMessage(Msg);
- end;
- end.