QQ2008自动聊天精灵delphi源码

 
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ExtCtrls,Registry, ExtDlgs, bsSkinShellCtrls,    BusinessSkinForm, bsSkinBoxCtrls, bsSkinCtrls;
type TTform1 = class(TForm)      GroupBox1: TGroupBox;      Bevel1: TBevel;      Label2: TLabel;      Bevel2: TBevel;      Bevel3: TBevel;      Bevel4: TBevel;      FindBtn: TSpeedButton;      Image1: TImage;      SendBtn: TSpeedButton;      LoadBtn: TSpeedButton;      loaddialog1: TOpenDialog;      ListBox1: TListBox;      bsBusinessSkinForm1: TbsBusinessSkinForm;      bsSkinOpenDialog1: TbsSkinOpenDialog;      AoutBtn: TSpeedButton;      procedure FormCreate(Sender: TObject);      procedure FindBtnClick(Sender: TObject);      procedure LoadBtnClick(Sender: TObject);      procedure SendBtnClick(Sender: TObject);      procedure AoutBtnClick(Sender: TObject);
private { Private declarations } public { Public declarations } end;
var Tform1: TTform1;
implementation {$R *.dfm} //定义一组全程变量 const     WinCaption07:string='聊天中';     WinCaption08:string='交谈中'; var    x:integer;    TextBoxNum:shortint; //QQ输入框是第几个对话框    SendButtonNum:shortint; //发送按钮是第几个按钮    QQInputBoxHandle,SendButtonHandle:HWND;//发送按钮和输入框句柄    StopSend:boolean; //=====================延时时程序=================== procedure Delay(msecs:integer); var FirstTickCount:longint; begin FirstTickCount:=GetTickCount; repeat      if STopSend then   exit ;      Application.ProcessMessages; until ((GetTickCount-FirstTickCount) >= Longint(msecs)); end; //=====================得到窗口内容=================== function GetWindowStr(Wnd: HWND): String; var Len: Integer; begin Len := SendMessage(Wnd, WM_GETTEXTLENGTH, 0, 0); SetLength(Result, Len + 1); SendMessage(Wnd, WM_GETTEXT, Length(Result), Longint(@Result[1])); end; //=====================得到所属类=================== function GetWindowClass(Wnd: HWND): String; begin SetLength(Result, 65); GetClassName(Wnd, @Result[1], 65); end;
//=====================查找子控件=================== function EnumChildProc(Wnd: HWND; lParam: LPARAM): Boolean; stdcall; var S, C: String; begin    S := GetWindowStr(Wnd);    C := GetWindowClass(Wnd);       X:=X+1;
     if   Pos('RichEdit', C) =1   then        begin          TextBoxNum:=TextBoxNum+1;          if   TextBoxNum =3 then QQInputBoxHandle :=Wnd;        end;      if (pos('发送',S) =1) and (Pos('Button', C) =1) then        begin          if   SendButtonNum=2 then   SendButtonHandle:=wnd;          SendButtonNum:= SendButtonNum+1;        end; Result := True; end; //=====================定义一个回调函数===================
function EnumWindowsProc(Wnd: HWND; lParam: LPARAM): Boolean; stdcall; var S, C: String; begin S := GetWindowStr(Wnd); C := GetWindowClass(Wnd); //看是07和08版QQ的标题吗? if (Pos(WinCaption07, S) >0) or (Pos(WinCaption08, S) >0) then    begin   //如果找到QQ窗体则找出所有控件      if not EnumChildWindows(Wnd, @EnumChildProc, lParam) then ;      Result := False;    end; Result := True; end; //=====================主表单初始化=================== procedure TTform1.FormCreate(Sender: TObject); begin    //初始化表单和列表框颜色    Tform1.color:=tcolor(rgb(236,233,216));    ListBox1.color:=Tcolor(rgb(96,96,97)); end;
//=====================查找QQ主窗体=================== procedure TTform1.FindBtnClick(Sender: TObject); begin    X:=0;    TextBoxNum:=1;    SendButtonNum:=1;
   try    if not EnumWindows(@EnumWindowsProc, Integer(Pointer(ListBox1))) then ;    finally      if X = 0 then messagebox( Tform1.Handle,'不能找到QQ发送窗口!','错误',MB_OK+MB_DEFBUTTON1 +MB_ICONHAND);   end;    listbox1.ItemIndex:=0;    if (QQInputBoxHandle<>0) and (SendButtonHandle <>0) then SendBtn.Enabled :=True; end;
//=====================装入聊天记录=================== procedure TTform1.LoadBtnClick(Sender: TObject); begin if bsSkinOpenDialog1.execute then     begin       ListBox1.Clear;       ListBox1.Items.LoadFromFile(bsSkinOpenDialog1.filename);     end; end;
//=====================可中断的连续发送================ procedure TTform1.SendBtnClick(Sender: TObject); var    SendTxt:string; begin
   StopSend := False; //把是否安暂停设为不停    if SendBtn.Caption='发 送' then      begin        SendBtn.Caption :='暂 停';      end    else      begin //如果是暂停按钮按下        SendBtn.Caption:='发 送';        StopSend:=True;      end;
   while (listbox1.ItemIndex<ListBox1.Items.Count-1) and (not StopSend)   do      begin         listbox1.ItemIndex:=listbox1.ItemIndex+1;
        //如果导入的文本文件里有空行,则跳过空行         while ListBox1.Items.strings[listbox1.ItemIndex]='' do listbox1.ItemIndex:=listbox1.ItemIndex+1;
        if STopSend then    exit; //如果暂停键按下         SendTxt :=ListBox1.Items.strings[listbox1.ItemIndex];         SendMessage(QQInputBoxHandle,EM_REPLACESEL,180,Integer(Pchar(SendTxt)));         delay(300);         SendMessage(SendButtonHandle,BM_CLICK,0,0);      end; end;
procedure TTform1.AoutBtnClick(Sender: TObject); begin    messagebox( Tform1.Handle,'QQ2008!','关于',MB_OK+MB_DEFBUTTON1 +MB_ICONQUESTION ); end;
end.

QQ2008自动聊天精灵delphi源码的更多相关文章

  1. [源码]Delphi源码免杀之函数动态调用 实现免杀的下载者

    [免杀]Delphi源码免杀之函数动态调用 实现免杀的下载者 2013-12-30 23:44:21         来源:K8拉登哥哥's Blog   自己编译这份代码看看 过N多杀软  没什么技 ...

  2. 转换GMT秒数为日期时间格式-Delphi源码

    转换GMT秒数为日期时间格式-Delphi源码.收藏最近在写PE分析工具的时候,需要转换TimeDateStamp字段值为日期时间格式,这是Delphi的源码. //把GMT时间的秒数转换成日期时间格 ...

  3. http代理工具delphi源码

    http://www.caihongnet.com/content/xingyexinwen/2013/0721/730.html http代理工具delphi源码 以下代码在 DELPHI7+IND ...

  4. 【krpano】二维码自动生成插件(源码+介绍+预览)

    简介 在krpano生成的全景支持HTML5在手机中展示,而在手机中打开全景网址时不方便,需要输入网址. 最近研究了如何让krpano全景根据自己当前的网址,自动生成二维码,并在电脑浏览时,可以展示出 ...

  5. Maven引入依赖后自动下载并关联源码(Source)

    好多用 Maven 的时候会遇到这样一个棘手的问题: 就是添加依赖后由于没有下载并关联源码,导致自动提示无法出现正确的方法名,而且不安装反编译器的情况下不能进入方法内部看具体实现 . 其实 eclip ...

  6. Android接受验证码自动填入功能(源码+已实现+可用+版本兼容)

    实际应用开发中,会经常用到短信验证的功能,这个时候如果再让用户就查看短信.然后再回到界面进行短信的填写,难免有多少有些不方便,作为开发者.本着用户至上的原则我们也应该来实现验证码的自动填写功能,还有一 ...

  7. IOS无限自动循环滚动banner(源码)

    本文转载至 http://blog.csdn.net/iunion/article/details/19080259  目前有很多APP都开始使用一些滚动banner,我自己也做了一个,部分算法没有深 ...

  8. Eclipse_插件_05_自动下载jar包源码插件

    一.Java Source Attacher 1.下载 官网:http://marketplace.eclipse.org/content/java-source-attacher#.U5RmTePp ...

  9. iOS精美过度动画、视频会议、朋友圈、联系人检索、自定义聊天界面等源码

    iOS精选源码 iOS 精美过度动画源码 iOS简易聊天页面以及容联云IM自定义聊天页面的实现思路 自定义cell的列表视图实现:置顶.拖拽.多选.删除 SSSearcher仿微信搜索联系人,高亮搜索 ...

随机推荐

  1. Linux系统官网下载

    CentOS-6.9-x86_64-bin-DVD1.isohttp://archive.kernel.org/centos-vault/6.9/isos/x86_64/CentOS-6.9-x86_ ...

  2. Git 更改远程地址

    查看远程地址 git remote -v 更换远程地址 git remote set-url origin 新的地址 更换之后可以查看一下 这个非常实用. 通常我们把gitlab服务器更换的时候,对应 ...

  3. Linux 设备驱动之 UIO 机制

    一个设备驱动的主要任务有两个: 1. 存取设备的内存 2. 处理设备产生的中断 对于第一个任务.UIO 核心实现了mmap()能够处理物理内存(physical memory),逻辑内存(logica ...

  4. LeetCode第[54]题(Java):Spiral Matrix

    题目:螺旋矩阵 难度:Medium 题目内容: Given a matrix of m x n elements (m rows, n columns), return all elements of ...

  5. 二维码(QR code)基本结构及生成原理

    什么是二维码 二维码 (2-dimensional bar code),是用某种特定的几何图形按一定规律在平面(二维方向上)分布的黑白相间的图形记录数据符号信息的. 在许多种类的二维条码中,常用的码制 ...

  6. 51nod 1639 递推

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1639 1639 绑鞋带 基准时间限制:1 秒 空间限制:131072 K ...

  7. 【专题】区间dp

    1.[nyoj737]石子合并 传送门:点击打开链接 描述    有N堆石子排成一排,每堆石子有一定的数量.现要将N堆石子并成为一堆.合并的过程只能每次将相邻的两堆石子堆成一堆,每次合并花费的代价为这 ...

  8. LeetCode OJ:Remove Element(移除元素)

    Given an array and a value, remove all instances of that value in place and return the new length. T ...

  9. PostgreSQL upset解决在插入过程中重复数据冲突

    关于重复行问题: 在SQL Server中则可以自动排出重复行,不需要处理.在Oracle中经常遇到upsert语法,来排出冲突行.在PostgreSQL中,也需要手动排出重复行,否则会爆出错误,up ...

  10. PostgreSQL.conf文件配置详解[转]

    一.连接配置与安全认证 1.连接Connection Settings   listen_addresses (string) 这个参数只有在启动数据库时,才能被设置.它指定数据库用来监听客户端连接的 ...