当前位置:首页 > 程序设计 > Delphi程序设计 > 游戏辅助 > 详细内容
SPY++ 结合Delphi7.0简单应用02010107-05源码
作者:admin  发布时间:2009-12-21  阅读次数:4896  字体大小: 【】 【】【

教学课题:SPY++ 结合Delphi7.0利用API函数mouse_event实现模拟鼠标按下数字键
教学目标:Delphi7.0编程坏境,以计算器为例模拟鼠标输入QQ号:854487915
教学要点:巩固mouse_event的用法
教学源码:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    lb1: TLabel;
    edt1: TEdit;
    btn1: TButton;
    lb2: TLabel;
    procedure btn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btn1Click(Sender: TObject);
var
  ck_hwnd:HWND;
  ck_R:TRect;
begin
  ck_hwnd:=FindWindow('SciCalc','计算器');
  edt1.Text := IntToHex(ck_hwnd,8);
  GetWindowRect(ck_hwnd,ck_R);
  lb2.Caption := IntToStr(ck_r.Left)+','+ IntToStr(ck_R.Top)+'/'+
  IntToStr(ck_R.Right)+ ','+ IntToStr(ck_R.Bottom );
  //实现按下数字键8
  SetCursorPos(350+ ck_R.Left ,150+ ck_R.Top )  ;
  mouse_event(MOUSEEVENTF_LEFTDOWN,350+ ck_R.Left,150+ ck_R.Top,0,0);
  Sleep(100);
  mouse_event(MOUSEEVENTF_LEFTUP,350+ ck_R.Left,150+ ck_R.Top,0,0);
  Sleep(100);
  //实现按下数字键5
  SetCursorPos(350+ ck_R.Left ,180+ ck_R.Top )  ;
  mouse_event(MOUSEEVENTF_LEFTDOWN,350+ ck_R.Left,180+ ck_R.Top,0,0);
  Sleep(100);
  mouse_event(MOUSEEVENTF_LEFTUP,350+ ck_R.Left,180+ ck_R.Top,0,0);
  Sleep(100);
  //实现按下数字键4
  SetCursorPos(310+ ck_R.Left ,180+ ck_R.Top )  ;
  mouse_event(MOUSEEVENTF_LEFTDOWN,310+ ck_R.Left,180+ ck_R.Top,0,0);
  Sleep(100);
  mouse_event(MOUSEEVENTF_LEFTUP,310+ ck_R.Left,180+ ck_R.Top,0,0);
  Sleep(100);
  //实现按下数字键4
  SetCursorPos(310+ ck_R.Left ,180+ ck_R.Top )  ;
  mouse_event(MOUSEEVENTF_LEFTDOWN,310+ ck_R.Left,180+ ck_R.Top,0,0);
  Sleep(100);
  mouse_event(MOUSEEVENTF_LEFTUP,310+ ck_R.Left,180+ ck_R.Top,0,0);
  Sleep(100);
  //实现按下数字键8
  SetCursorPos(350+ ck_R.Left ,150+ ck_R.Top )  ;
  mouse_event(MOUSEEVENTF_LEFTDOWN,350+ ck_R.Left,150+ ck_R.Top,0,0);
  Sleep(100);
  mouse_event(MOUSEEVENTF_LEFTUP,350+ ck_R.Left,150+ ck_R.Top,0,0);
  Sleep(100);
  //实现按下数字键7
  SetCursorPos(310+ ck_R.Left ,150+ ck_R.Top )  ;
  mouse_event(MOUSEEVENTF_LEFTDOWN,310+ ck_R.Left,150+ ck_R.Top,0,0);
  Sleep(100);
  mouse_event(MOUSEEVENTF_LEFTUP,310+ ck_R.Left,150+ ck_R.Top,0,0);
  Sleep(100);
  //实现按下数字键9
  SetCursorPos(390+ ck_R.Left ,150+ ck_R.Top )  ;
  mouse_event(MOUSEEVENTF_LEFTDOWN,390+ ck_R.Left,150+ ck_R.Top,0,0);
  Sleep(100);
  mouse_event(MOUSEEVENTF_LEFTUP,390+ ck_R.Left,150+ ck_R.Top,0,0);
  Sleep(100);
  //实现按下数字键1
  SetCursorPos(310+ ck_R.Left ,210+ ck_R.Top )  ;
  mouse_event(MOUSEEVENTF_LEFTDOWN,310+ ck_R.Left,210+ ck_R.Top,0,0);
  Sleep(100);
  mouse_event(MOUSEEVENTF_LEFTUP,310+ ck_R.Left,210+ ck_R.Top,0,0);
  Sleep(100);
  //实现按下数字键5
  SetCursorPos(350+ ck_R.Left ,180+ ck_R.Top )  ;
  mouse_event(MOUSEEVENTF_LEFTDOWN,350+ ck_R.Left,180+ ck_R.Top,0,0);
  Sleep(100);
  mouse_event(MOUSEEVENTF_LEFTUP,350+ ck_R.Left,180+ ck_R.Top,0,0);

end;

end.

来源:潇潇的编程网站 http://www.wgbcw.cn
我要评论
  • 匿名发表
  • [添加到收藏夹]
  • 发表评论:(匿名发表无需登录,已登录用户可直接发表。) 登录状态:未登录
最新评论
所有评论[1]
    暂无已审核评论!
Web Lite SWeTE: Simple Website Translation Engine
 


设为首页 | 加入收藏 | 意见建议 | 友情链接 | 版权声明 | 管理登陆 | 编程论坛 | 给我留言

声明:本网站部分稿件来源的所有文字、图片和音视频稿件,来自互联网,若侵犯您的权利,请来信告知,我们将在第一时间内删除!

Copyright 2009-2015 redrose ( wgbcw.cn ) All rights reserved ICP备案编号:滇ICP备09007156号 Dict.cn

点击这里给我发消息
点击这里给我发消息
安全联盟站长平台