WM_GETTEXT,WM_SETTEXT,WM_PASTE ( 积分: 50 )

  • 主题发起人 主题发起人 LoveShanShan
  • 开始时间 开始时间
L

LoveShanShan

Unregistered / Unconfirmed
GUEST, unregistred user!
尝试做一个QQ尾巴,但是腾迅好像做了防护……
unit Main;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls,Clipbrd;

type
TForm1 = class(TForm)
tvWindows: TTreeView;
EdtWndText: TEdit;
Label1: TLabel;
Label2: TLabel;
EdtHwndValue: TEdit;
Label3: TLabel;
EdtWndClassName: TEdit;
BtnSet: TButton;
BtnRefresh: TButton;
MemWnds: TMemo;
procedure FormCreate(Sender: TObject);
procedure BtnRefreshClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
tv:TTreeView;
Mem:TMemo;

implementation

{$R *.dfm}

function EnumWndProc(hWnd:HWND;lParam:LPARAM):BOOL;stdcall;
var
lpBuffer:PAnsiChar;
WndTxt,WndCls:string;
iLen:Integer;
begin
GetMem(lpBuffer,MAX_PATH+1);
GetWindowText(hWnd,lpBuffer,MAX_PATH);
WndTxt:=StrPas(lpBuffer);
if Pos('聊天中',WndTxt)>0 then
EnumChildWindows(hWnd,@EnumWndProc,1);
if lParam=1 then
begin
RealGetWindowClass(hWnd,lpBuffer,MAX_PATH);
WndCls:=StrPas(lpBuffer);
if CompareText(WndCls,'RICHEDIT')=0 then
begin
Mem.Lines.Add(Format('Handle Value:0x%x,Window Class Name:%s,Window Text:%s',[hWnd,WndCls,WndTxt]));
ClipBoard.AsText:='www.delphibbs.com';
SendMessage(hWnd,WM_PASTE,0,0);//实际证明这是无效的。为什么粘贴不上呢
//用WM_SETTEXT也不起作用,WM_GETTEXTLENGTH能得到文本长度,但得不到具体字符串。
end;
//if (CompareText(WndCls,'Button')=0) and (Pos('发送',WndTxt)>0) then
//SendMessage(hWnd,BM_CLICK,0,0);
end;
Result:=True;
end;

procedure EnumWnds;
begin
EnumWindows(@EnumWndProc,0);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
tv:=tvWindows;
Mem:=MemWnds;
Mem.Clear;
EnumWnds;
end;

procedure TForm1.BtnRefreshClick(Sender: TObject);
begin
MemWnds.Clear;
EnumWnds;
end;

end.
 
qq对自己的软件做了好多防护
你的代码应该没问题,但是这种方式,QQ可以首先截获消息并判断是否为自身调用发送的消息,如果判断为外来消息则屏蔽掉,所以你这种方法技术上正确,但对QQ确不可行
 
现在QQ尾巴 是不行了 一些windows消息对QQ没作用 前几天我也弄过 也不行
只能重新发了
我做的 就还查一点了 就是搞不定

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
Timer1: TTimer;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
function InstallHook(MyHandle: HWND):boolean;external 'QQHook.dll';
function UnInstallHook:boolean; external 'QQHook.dll';
// 获得窗口文本
function GetWndText(WinHandle: HWND): String;
Var
bufCount: LongInt;
WinText: PChar;
begin
bufCount:= SendMessage(WinHandle,WM_GETTEXTLENGTH,0,0)+1;
GetMem(WinText,bufCount);
try
GetWindowText(WinHandle,WinText,bufCount);
Result:=StrPas(WinText);
finally
FreeMem(WinText);
end;
end;

function GetQQWnd: HWND;
var
hCurrentWindow: HWnd;
WndText: String;
Boo: Boolean;
begin
hCurrentWindow := GetWindow(Application.Handle, GW_HWNDFIRST);
while hCurrentWindow <> 0 do
begin
WndText := GetWndText(hCurrentWindow);
Boo := (Pos('聊天中',WndText)>0) or (Pos('发送消息',WndText)>0) or
(Pos('群',WndText)>0);
if Boo then
begin
Result := hCurrentWindow;
Exit;
end;
hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);
end;
Result := 0;
end;

procedure SpyQQDlg;
var
qqWnd:HWND;
begin
qqWnd:= GetQQWnd;
if qqWnd = 0 then Exit;
InstallHook(qqWnd);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
UnInstallHook;;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
UnInstallHook;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
SpyQQDlg;
end;

end.



library QQHook;
uses
Windows,
Messages ;
{$R *.res}
var
MyHook,KeyHook: HHOOK;
procedure PasteText;
var
hMem: HGLOBAL;
pStr: Pchar;
begin
hMem := GlobalAlloc(GHND or GMEM_SHARE, 256);
try
pStr := GlobalLock(hMem);
LstrCpy(pStr,Pchar('欢迎光临绿荫网络http://www.lvyin.net'));
try
OpenClipboard(0);
EmptyClipboard;
SetClipBoardData(CF_TEXT,hMem);
finally
CloseClipBoard;
end;
finally
GlobalFree(hMem);
end;
Keybd_Event(VK_CONTROL,MapVirtualKey(VK_CONTROL,0),0,0);
Keybd_Event(ord('V'),MapVirtualKey(ord('V'),0),0,0);
Keybd_Event(ord('V'),MapVirtualKey(ord('V'),0),KEYEVENTF_KEYUP,0);
Keybd_Event(VK_CONTROL,MapVirtualKey(VK_CONTROL,0),KEYEVENTF_KEYUP,0);
end;

function HookProc(icode:Integer;wparam:WPARAM;lparam:LPARAM):LRESULT;stdcall;
var
P:TCWPStruct;
begin
Result := 0 ;
if icode <0 then
Result := CallNextHookEx(MyHook,icode,wparam,lparam)
else
begin
p:= PCWPStruct(lparam)^;
if P.message = WM_COMMAND then
begin
if LOWORD(P.wParam) = $0000077E then
begin
PasteText;
// Keybd_Event(VK_RETURN,MapVirtualKey(VK_RETURN,0),0,0);
// Keybd_Event(VK_RETURN,MapVirtualKey(VK_RETURN,0),KEYEVENTF_KEYUP,0);
SendMessage(Hwnd(P.lParam),WM_LBUTTONDOWN,MK_LBUTTON,0);
SendMessage(Hwnd(P.lParam),WM_LBUTTONUP,0,0);
Result:= 1;
end;
end;
end;
end;

function KeyHookProc(icode:Integer;wparam:WPARAM;lparam:LPARAM):LRESULT;stdcall;
var
boo: Boolean;
begin
Result:= 0;
if icode < 0 then
Result:= CallNextHookEx(KeyHook,icode,wparam,lparam)
else
begin
if PMsg(lparam)^.message=WM_KEYDOWN then
begin
Boo:= (PMsg(lparam)^.wParam=VK_RETURN) or ((PMsg(lparam)^.wParam=VK_RETURN) and ((GetKeyState(VK_CONTROL) and $8000)<>0));
if Boo then
begin
PasteText;
// SendMessage(Hwnd(PMsg(lparam)^.lParam),WM_LBUTTONDOWN,MK_LBUTTON,0);
// SendMessage(Hwnd(PMsg(lparam)^.lParam),WM_LBUTTONUP,0,0);
Result:= 1;
end;
end;
end;
end;

function InstallHook(WinHandle: HWND):boolean;export;
var
dwThreadID: Cardinal;
begin
Result := False;
if WinHandle = 0 then Exit;
dwThreadID := GetWindowThreadProcessID(WinHandle,nil);
MyHook := SetWindowsHookEx(WH_CALLWNDPROC,@HookProc,Hinstance,dwThreadID);
KeyHook := SetWindowsHookEx(WH_GETMESSAGE,@KeyHookProc,Hinstance,dwThreadID);
Result := (MyHook <> 0) and (KeyHook <> 0);
end;

function UnInstallHook:boolean; export;
begin
MyHook := 0;
KeyHook := 0;
Result := UnHookWindowsHookEx(MyHOOK) and UnHookWindowsHookEx(KeyHook);
end;
exports
InstallHook, UnInstallHook;

end.
 
关于搞QQ的 麻子做了很多
 
qq对组件做了很多防护,要么子类化控件,对某些消息过滤,要么不使用windows控件,而是自己画上去
 
这样啊,结贴,以后多多交流。
 
还没有结帖子啊
 
QQ 尾巴可以实现 得用EM_REPLACESEL 这个消息 不要用WM_SETTEXT
 
楼主失踪好久了 .... 真得报警了
 
看我这个就实现了:
http://download.csdn.net/source/161172
 
后退
顶部