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
lpBufferAnsiChar;
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.
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
lpBufferAnsiChar;
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.