博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
鼠标轨迹记录和回复
阅读量:3588 次
发布时间:2019-05-20

本文共 2250 字,大约阅读时间需要 7 分钟。

unit mousereplay;
interface
uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
  TForm6 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form6: TForm6;
  eventarr:array[0..1000] of EVENTMSG;
  eventlog:integer;
  playlog:integer;
  hhook,hplay:integer;
  bdelay:bool;
implementation
{$R *.dfm}
function playproc(icode:integer;wparam:WPARAM;lparam:LPARAM):LRESULT;stdcall;
begin
  result:=0;
  if icode<0 then
    result:=callnexthookex(hplay,icode,wparam,lparam)
  else if icode=HC_SYSMODALON then       //不允许回放
  else if icode=HC_SYSMODALOFF then  //允许回放
  else if icode=HC_GETNEXT then
  begin
     if bdelay then
     begin
        bdelay:=false;
        result:=50;
     end;
     pEVENTMSG(lparam)^:=eventarr[playlog];
  end
  else if icode=HC_SKIP then
  begin
    bdelay:=true;
    playlog:=playlog+1;
  end;
  if playlog>=eventlog then
  begin
    unhookwindowshookex(hplay);
  end;
end;
function hookproc(icode:integer;wparam:WPARAM;lparam:LPARAM):LRESULT;stdcall;
begin
  result:=0;
  if icode<0 then
    result:=callnexthookex(hhook,icode,wparam,lparam)
  else if icode=HC_SYSMODALON then //不允许记录
  else if icode=HC_SYSMODALOFF then //允许记录
  else if icode=HC_ACTION then
  begin
    eventarr[eventlog]:=peventMsg(lparam)^;
    inc(eventlog);
    if eventlog>=1000 then
    begin
      unhookwindowshookex(hhook);
    end;
  end;
end;
procedure TForm6.Button1Click(Sender: TObject);
begin
  eventlog:=0;
  //建立键盘鼠标操作链
  hhook:=setwindowshookex(WH_JOURNALRECORD,hookproc,hinstance,0);
  button2.Enabled:=true;
  button1.Enabled:=false;
  button3.Enabled:=false;
end;
procedure TForm6.Button2Click(Sender: TObject);
begin
  unhookwindowshookex(hhook);
  hhook:=0;
  button1.Enabled:=true;
  button2.Enabled:=false;
  button3.Enabled:=true;
end;
procedure TForm6.Button3Click(Sender: TObject);
begin
  playlog:=0;
  hplay:=setwindowshookex(WH_JOURNALRECORD,playproc,hinstance,0);
end;
procedure TForm6.FormCreate(Sender: TObject);
begin
  button2.Enabled:=false;
  button3.Enabled:=false;
end;

end.

------------------------------------------

不知为啥,回放不了

转载地址:http://pmvwn.baihongyu.com/

你可能感兴趣的文章
设计模式之神奇的单例模式
查看>>
linux系统设置oracle开机自启
查看>>
数据库的五种索引类型
查看>>
设计模式之原型模式
查看>>
设计模式之建造者模式
查看>>
设计模式之代理模式
查看>>
设计模式之门面模式
查看>>
设计模式之装饰器模式
查看>>
设计模式之享元模式
查看>>
设计模式之组合模式
查看>>
设计模式之委派模式
查看>>
设计模式之模板方法模式
查看>>
设计模式之策略模式
查看>>
设计模式之责任链模式
查看>>
怎么成为一个合格的ERP系统管理员
查看>>
企业为什么要用ERP
查看>>
ERP计划层次探讨
查看>>
ERP的五大核心思想
查看>>
ERP、PLM是什么意思?ERP、PLM有什么内在联系
查看>>
公司升级ERP管理系统的三大诱因
查看>>