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. windows远程登录最大连接数

  2. scala学习手记8 - 自适应的默认做法

    scala有一些默认做法,会让代码更简洁.更易读写,下面列出了这样几个特性: 1. 支持脚本.scala支持脚本,因此无须将所有的代码都放到类里.如果脚本可以满足需求,就将代码放到一个脚本里,无须再创 ...

  3. Author Agreement

    Dear Editor,We the undersigned declare that this manuscript entitled “文章标题” is original, has not bee ...

  4. 通过Google Custom Search API 进行站内搜索

    今天突然想把博客的搜索改为google的站内搜索,印象中google adsense中好像提高这个站内搜索的代码,但苦逼的是google adsense帐号一直审核不通过,所以只能通过google c ...

  5. bash echo color

    原文:https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux $ ; i ...

  6. Java 文件上传中转

    org.apache.commons.httpclient.methods.multipart Class MultipartRequestEntity java.lang.Object org.ap ...

  7. 【Java】抽象类和接口

    一.抽象类和抽象方法 1.什么是抽象类 普通类是一个完善的功能类,可以直接产生实例化对象,并且在普通类中可以包含有构造方法.普通方法.static方法.常量和变量等内容. 但是普通类中不能有抽象方法, ...

  8. hdu4185

    题解:每两个联通的油井建边 然后二分图最大匹配 最后答案除以2 代码: #include<cstdio> #include<cmath> #include<cstring ...

  9. 2017.11.16 STM8L052 温度控制器

    1 J-link和ST-link的兼容性 STM8只能用ST-link.J-link兼容所有的(大部分而已)的ARM内核IC mark:  http://bbs.eeworld.com.cn/thre ...

  10. Chrome字体变粗

    如图.解决方案,看看CSS中用了什么字体,卸载某个字体. 因为我装了一个新的字体,CSS中有这个字体的网页都会变粗.删掉这个字体就恢复正常了