本文主要讲解的是delphi编程模拟发送QQ消息!即利用外部程序发送QQ消息,代码很少,其实原理就是,找到QQ消息输入框,然后利用sendmessage传送一个文本信息进去,再找到发送按钮,模拟点击按下发送按钮就可以:
var hd,hwnd1,hwnd2,hwnd3,hwnd4:DWORD;
begin
//学Delphi网群 - 群
hwnd1:=FindWindow(nil,'学Delphi网群 - 群');//根据标题名找handle
if hwnd1<>0 then
begin
hwnd2 := FindWindowEx(hwnd1, THandle(nil),'AfxWnd42',nil);
hwnd2 := FindWindowEx(hwnd1,hwnd2,'AfxWnd42',nil);
hwnd2 := Findwindowex(hwnd2,0,'RichEdit20A',nil);
if Memo1.Text<>'' then
begin
SendMessage(hwnd2, EM_ReplaceSel, 0, Integer(pchar(Memo1.Text)));
hwnd4:= findwindowex(hwnd1,0,'Button','发送(S)'); //找到送信息按钮,
SendMessage (hwnd4,WM_LBUTTONDOWN , 0, 0); //模拟按下
SendMessage (hwnd4,WM_LBUTTONUp,0,0);
end
else
end;
end;
2009/2011/2010不能使用;