QQ尾巴的發作情況
程序實現
一
QQ消息發送窗口有兩種
通過枚舉窗口就可找到相應的句柄
// 取得QQ的發送消息窗口
function GetQQWnd: HWND;
var
hCurrentWindow: HWnd;
WndText:String;
begin
hCurrentWindow := GetWindow(Application
while hCurrentWindow <>
begin
WndText:=GetWndText(hCurrentWindow);
if (Pos(
begin
Result:=hCurrentWindow;
Exit;
end;
hCurrentWindow := GetWindow(hCurrentWindow
end;
Result:=
end;
二
找到了QQ的發送消息窗口後
btnWnd:=GetDlgItem(qqWnd
來獲得
三
消息文本框並不好找
txtWnd:=GetWindow(GetDlgItem(qqWnd
來獲得
四
要獲取原消息文本框的文本
// 獲得窗口文本
function GetWndText(hWnd: HWND): String;
Var
Ret:LongInt;
mText:PChar;
Buf:Integer;
begin
Ret:=SendMessage(hWnd
GetMem(mText
try
Buf:=LongInt(mText);
SendMessage(hWnd
Result:=StrPas(mText);
finally
FreeMem(mText
end;
end;
五
與取文本相反
// 發送文本到窗口
procedure SetWndText(hWnd: HWND; Text: String);
Var
Ret:LongInt;
mText:PChar;
Buf:Integer;
begin
GetMem(mText
StrCopy(mText
try
Buf:=LongInt(mText);
SendMessage(hWnd
finally
FreeMem(mText
end;
end;
六
一切都准備好了
SendMessage(btnWnd
SendMessage(btnWnd
通過模擬一個鼠標在
七
八
unit Unit
interface
uses
Windows
Dialogs
type
TForm
Timer
Button
Edit
Label
Button
procedure Timer
procedure Button
procedure Button
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form
implementation
{$R *
// 獲得窗口文本
function GetWndText(hWnd: HWND): String;
Var
Ret:LongInt;
mText:PChar;
Buf:Integer;
begin
Ret:=SendMessage(hWnd
GetMem(mText
try
Buf:=LongInt(mText);
SendMessage(hWnd
Result:=StrPas(mText);
finally
FreeMem(mText
end;
end;
// 發送文本到窗口
procedure SetWndText(hWnd: HWND; Text: String);
Var
Ret:LongInt;
mText:PChar;
Buf:Integer;
begin
GetMem(mText
StrCopy(mText
try
Buf:=LongInt(mText);
SendMessage(hWnd
finally
FreeMem(mText
end;
end;
// 取得QQ的發送消息窗口
function GetQQWnd: HWND;
var
hCurrentWindow: HWnd;
WndText:String;
begin
hCurrentWindow := GetWindow(Application
while hCurrentWindow <>
begin
WndText:=GetWndText(hCurrentWindow);
if (Pos(
begin
Result:=hCurrentWindow;
Exit;
end;
hCurrentWindow := GetWindow(hCurrentWindow
end;
Result:=
end;
// 定時處理
procedure TimerProc;
var
qqWnd
Msg:String;
begin
qqWnd:=GetQQWnd;
if qqWnd=
btnWnd:=GetDlgItem(qqWnd
txtWnd:=GetWindow(GetDlgItem(qqWnd
if (btnWnd=
Msg:=GetWndText(txtWnd);
Msg:=Msg+#
SetWndText(txtWnd
SendMessage(btnWnd
SendMessage(btnWnd
end;
procedure TForm
begin
TimerProc;
end;
procedure TForm
begin
Timer
if Timer
Button
else
Button
end;
procedure TForm
begin
Timer
end;
end
九
上面只講述了QQ消息自動發送的主要功能
另
From:http://tw.wingwit.com/Article/program/Delphi/201311/8482.html