delphi写QQ消息群发(模拟按键精灵)


本文整理自网络,侵删。

 

使用函数:EnumWindows,EnumWindowsProc

源代码奉上:
unit QMsgMainFrm;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Clipbrd;
 
type
  TForm1 = class(TForm)
    edtMsg: TEdit;
    lblTip: TLabel;
    btnTry: TButton;
    lblMsgWindow: TLabel;
    lblMsgContextWindow: TLabel;
    procedure btnTryClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
  function EnumWindowsProc(hwnd: HWND; lParam: LPARAM): Boolean ;stdcall;
implementation
 
{$R *.dfm}
 
procedure TForm1.btnTryClick(Sender: TObject);
begin
  if Trim(edtMsg.Text) = '' then
  begin
    ShowMessage('请输入要发送的消息,消息不能为空');
  end else
  begin
    EnumWindows(@EnumWindowsProc ,0);
  end;
end;
 
function EnumWindowsProc(hwnd: HWND; lParam: LPARAM): Boolean ;stdcall;
var
  WindowText    : string  ;
  WindowClass   : string  ;
  SendHwnd      : DWORD   ;     
  tdiahandle    : THandle ;
  tedithandle   : THandle ;
  tduihuakhandle: THandle ;
  c: Cardinal;
  ProcessHandle:LongWord;
 begin
  if ( IsWindowVisible(hwnd) or IsIconic(hwnd) ) and
       (
        (GetWindowLong(hwnd, GWL_HWNDPARENT) = 0) or
        (GetWindowLong(hwnd, GWL_HWNDPARENT) = Longint(GetDesktopWindow))
       ) and
     ( GetWindowLong(hwnd, GWL_EXSTYLE) and WS_EX_TOOLWINDOW = 0)  then
  begin
    SetLength(WindowText, GetWindowTextLength(hwnd)+2);
    Getwindowtext(hwnd, Pchar(WindowText), GetWindowTextLength(hwnd)+2);
    WindowText := string(Pchar(WindowText));
    SetLength(WindowClass, 512);
    GetClassName(hwnd, Pchar(WindowClass), 512);
    WindowClass := string(Pchar(WindowClass) );
    if SameStr(WindowClass , 'TXGuiFoundation') then
    begin
      BringWindowToTop(hwnd);
      Form1.lblMsgContextWindow.Caption := WindowText;
      if Clipboard.HasFormat(CF_TEXT) then
        Clipboard.Clear;
      Form1.edtMsg.SelectAll;
      Form1.edtMsg.CopyToClipboard;
      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);
      keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0),0 ,0);
    end;
  end;
  Result := True;
 end;
end.
我们在网络中经常会有这样的需求,有一篇推销内容要发送到QQ群或者QQ好友,手动一个一个发实在是麻烦的很,那么就需要有一套好的工具来辅助我们,所以就写了这么一个东东。大家多多支持。

本文地址:http://blog.csdn.net/sushengmiyan/article/details/8774780

相关阅读 >>

如何用Delphi实现子目录级的文件查询

Delphi [fmx]如何使用剪贴板

Delphi 拷贝edit编辑框中的内容

Delphi 限制窗体大小的最大值与最小值

Delphi 通得进程id获取主窗口句柄

Delphi 从 .lnk 文件获取真正路径的程序

Delphi idtcpclient1实现端口扫描器

Delphi xe5 中tmemo控件的应用――for android

Delphi createmessagedialog

Delphi sccoloredid,星际争霸彩色 id 修改器 v0.2.0,支持 windows vista

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...