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. Python中求阶乘(factorial)

    1. math.factorial(x) import math value = math.factorial(x) 2. reduce函数 def factorial(n): return redu ...

  2. skynet 创建存储过程脚本

    最近主程更改了数据库的操作方案,由之前的拼写sql脚本转为在mysql端创建好存储过程后,直接调用存储过程. 首先对一个表测试上述过程: 数据库端存储过程:(测试表) CREATE TABLE `ra ...

  3. 在myeclipse中安装svn

    首先下载site.zip,然后解压.在myeclipse的安装目录中的dropins文件夹中新建svn文件夹,把site中的features和plugins文件夹复制到svn中即可.然后重启Myecl ...

  4. javascrip函数简单介绍

    JavaScript 函数定义JavaScript 使用关键字 function 定义函数.函数可以通过声明定义,也可以是一个表达式.函数声明在之前的教程中,你已经了解了函数声明的语法 :functi ...

  5. C++(十五) — sizeof 运算符

    1.基本数据类型 sizeof 是一个关键字,它是一个编译时运算符,用于判断变量或数据类型的字节大小. sizeof 运算符可用于获取类.结构.共用体和其他用户自定义数据类型的大小. 使用 sizeo ...

  6. Java实现数组去除重复数据的方法详解

    一.用List集合实现 int[] str = {5, 6, 6, 6, 8, 8, 7,4}; List<Integer> list = new ArrayList<Integer ...

  7. oepnstack笔记

    openstack简介: 组件:Nova 提供计算资源池neutron 网络资源管理horizon 基于openstack API借口使用django开发的web管理 组件:Nova 提供计算资源池n ...

  8. django model_fields_validators 前端页面编辑自定义验证

    # model_field_validators.py import re from django.core.exceptions import ValidationError from django ...

  9. elementUI表格合并单元格

    相信你肯定看了 ElementUI 官方文档了,没看的话先去看下表格各个属性的意义,方便下文阅读:传送门 但你会发现此例过于简单,死数据,但我们开发的时候往往都是后台传递过来的数据,导致我们 rows ...

  10. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource

    二月 20, 2017 3:09:47 下午 org.apache.catalina.startup.SetAllPropertiesRule begin警告: [SetAllPropertiesRu ...