捐赠 | 广告 | 注册 | 发布 | 上传 | 关于我们    
  沪ICP备05001939号 DELPHI盒子 | 盒子论坛 | 盒子文章 | 盒子问答悬赏 | 最新更新 | 论坛检索 | 下载中心 | 高级搜索    
  精品专区 | 繁體中文 | 奖励公告栏 | 直通车账号登陆 | 关闭GOOGLE广告 | 临时留言    
盒子资源分类
全部展开 - 全部合拢
keyspy键盘HOOK控件(无下载!)
关键字:keyspy键盘HOOK控件
来 自:原创
平 台:Win9x,Win2k/XP/NT,Win2003 下载所需:0 火柴
深浅度:初级 完成时间:2009/10/29
发布者:xuchuantao17 发布时间:2009/10/29
编辑器:DELPHI7 语  种:简体中文
分 类:其他 下载浏览:387/12657
加入到我的收藏
下载错误报错
登陆以后才能下载
 用户名:
 密 码:
自动登陆(30天有效)
图片如果打不开,说明流量不够了,请稍候下载……
unit   Keyspy;
    
  interface   
    
  uses   
      {$IFDEF   WIN32}   Windows,   {$ELSE}   WinTypes,   WinProcs,{$ENDIF}   
      SysUtils,   Controls,   Classes,   Messages,   Forms;   

  type   
      TOnKeySpy   =   procedure(Sender:   TObject;   Key:   Byte;   KeyStr:   String)   of   object;   
      TKeySpy   =   class(TComponent)   
      private   
          FWindowHandle:   HWnd;   
          FOnKeySpyDown,   FOnKeySpyUp:   TOnKeySpy;   
          FOnKeyword:   TNotifyEvent;   
          FEnabled:   Boolean;   
          FKeyword,   
          KeyComp:   String;   
    
          OldKey:   Byte;   
          LShiftUp,   RShiftUp:   Boolean;   
          procedure   UpdateTimer;   
          procedure   SetEnabled(Value:   Boolean);   
          procedure   WndProc(var   Msg:   TMessage);   
      protected   
          procedure   KeySpy;   dynamic;   
      public   
          constructor   Create(AOwner:   TComponent);   override;   
          destructor   Destroy;   override;   
      published   
          property   Enabled:   Boolean   read   FEnabled   write   SetEnabled;   
          property   Keyword:   String   read   FKeyword   write   FKeyword;   
          property   OnKeySpyDown:   TOnKeySpy   read   FOnKeySpyDown   write   FOnKeySpyDown;   
          property   OnKeySpyUp:   TOnKeySpy   read   FOnKeySpyUp   write   FOnKeySpyUp;   
          property   OnKeyword:   TNotifyEvent   read   FOnKeyword   write   FOnKeyword;   
      end;   
    
  procedure   Register;   
    
  implementation   
    
  const   
      LowButtonName:   Array[1..88]   of   PChar   =   ('--Esc','1','2','3','4','5','6','7','8','9',   
          '0','-','=','--BkSp','--Tab','q','w','e','r','t',   
          'y','u','i','o','p','[',']','--Enter','--Ctrl','a',   
          's','d','f','g','h','j','k','l',';','''','`',   
          '--LShift   Down','\','z','x','c','v','b','n','m',',',   
          '.','/','--RShift   Down','--Gray*','--Alt','--Space',   
          '--CapsLock','--F1','--F2','--F3','--F4','--F5',   
          '--F6','--F7','--F8','--F9','--F10',   
          '--NumLock','--ScrollLock','--Home','--Up',   
          '--PgUp','--Gray-','--Left','--*5*','--Right',   
          '--Gray+','--End','--Down','--PgDown','--Ins',   
          '--Del','--LShift   Up','--RShift   Up',   
          '--Unknown','--F11','--F12');   
    
      HiButtonName:   Array[1..88]   of   PChar   =   ('--Esc','!','@','#','$','%','^','&','*','(',   
          ')','_','+','--BkSp','--Tab','Q','W','E','R','T',   
          'Y','U','I','O','P','{','}','--Enter','--Ctrl','A',   
          'S','D','F','G','H','J','K','L',':','"','~',   
          '--LShift   Down','|','Z','X','C','V','B','N','M','<',   
          '>','?','--RShift   Down','--Gray*','--Alt','--Space',   
          '--CapsLock','--F1','--F2','--F3','--F4','--F5',   
          '--F6','--F7','--F8','--F9','--F10',   
          '--NumLock','--ScrollLock','--Home','--Up',   
          '--PgUp','--Gray-','--Left','--*5*','--Right',   
          '--Gray+','--End','--Down','--PgDown','--Ins',   
          '--Del','--LShift   Up','--RShift   Up',   
          '--Unknown','--F11','--F12');   
    
  constructor   TKeySpy.Create(AOwner:   TComponent);   
  begin   
      inherited   Create(AOwner);   
      LShiftUp   :=   True;   
      RShiftUp   :=   True;   
      FEnabled   :=   false;   
      FWindowHandle   :=   AllocateHWnd(WndProc);   
      if   FEnabled   then   UpdateTimer;   
  end;   
    
  destructor   TKeySpy.Destroy;   
  begin   
      FEnabled   :=   False;   
      UpdateTimer;   
      DeallocateHWnd(FWindowHandle);   
      inherited   Destroy;   
  end;   
    
  procedure   TKeySpy.WndProc(var   Msg:   TMessage);   
  begin   
      with   Msg   do   
          if   Msg   =   WM_TIMER   then   
          try   
          KeySpy;   
          except   
          Application.HandleException(Self);   
          end   
          else   
          Result   :=   DefWindowProc(FWindowHandle,   Msg,   wParam,   lParam);   
  end;   
    
  procedure   TKeySpy.UpdateTimer;   
  var   
      b:   Byte;   
  begin   
      KillTimer(FWindowHandle,   1);   
      if   FEnabled   then   
        begin   
          asm   
          mov   al,   60h   
          mov   b,   al   
          end;   
          OldKey   :=   b;   
          if   SetTimer(FWindowHandle,   1,   1,   nil)   =   0   then   
          raise   EOutOfResources.Create('No   timers');   
        end;   
  end;   
    
  procedure   TKeySpy.SetEnabled(Value:   Boolean);   
  begin   
      if   Value   <>   FEnabled   then   
      begin   
          FEnabled   :=   Value;   
          UpdateTimer;   
      end;   
  end;   
    
  procedure   TKeySpy.KeySpy;   
  var   
      Key:   Byte;   
      St:   String;   
  begin   
      asm   
          in   al,   60h   
          mov   Key,   al   
      end;   
      if   Key   =   170   then   
        begin   
          Key   :=   84;   
          LShiftUp   :=   True;   
        end;   
      if   Key   =   182   then   
        begin   
          Key   :=   85;   
          RShiftUp   :=   True;   
        end;   
      if   Key   =   42   then   LShiftUp   :=   False;   
      if   Key   =   54   then   RShiftUp   :=   False;   
      if   Key   <>   OldKey   then   
        begin   
          OldKey   :=   Key;   
          if   Key   <=   88   then   
          if   Assigned(FOnKeySpyDown)   then   
          begin   
          if   LShiftUp   and   RShiftUp   then   
          St   :=   StrPas(LowButtonName[Key])   
          else   
          St   :=   StrPas(HiButtonName[Key]);   
    
          FOnKeySpyDown(Self,   Key,   St);   
    
          KeyComp   :=   KeyComp   +   St;   
          if   Length(KeyComp)   >   Length(FKeyword)   then   
          begin   
          Move(KeyComp[Length(St)   +   1],   KeyComp[1],   Length(KeyComp));   
          {$IFDEF   WIN32}   
          SetLength(KeyComp,   Length(FKeyword));   
          {$ELSE}   
          KeyComp[0]   :=   char(Length(FKeyword));   
          {$ENDIF}   
          end;   
    
          if   KeyComp   =   FKeyword   then   FOnKeyword(Self);   
          end   
          else   
          else   
          if   Assigned(FOnKeySpyUp)   and   (Key   -   128   <=   88)   then   
          begin   
          if   LShiftUp   and   RShiftUp   then   
          St   :=   StrPas(LowButtonName[Key   -   128])   
          else   
          St   :=   StrPas(HiButtonName[Key   -   128]);   
          FOnKeySpyUp(Self,   Key,   St)   
          end;   
        end;   
  end;   
    
  procedure   Register;   
  begin   
      RegisterComponents('smilboy',   [TKeySpy]);   
  end;   
    
  end.
Google
 
本站原创作品,未经作者许可,严禁任何方式转载;转载作品,如果侵犯了您的权益,请联系我们
龙脉加密锁 15元起 Grid++Report 报表 申请支付@网
 相关文章
没有相关文章
相关评论
共有评论2条 当前显示最后2条评论
guang168332 2009/11/5 8:41:23
看源码貌似是设置一个时钟定时拦截键盘的键码,然后执行事件。。。。
hrx8889 2010/1/31 0:23:25
这个是什么格式`  怎么编辑啊?
我要发表评论 查看全部评论
 
  DELPHI盒子版权所有 1999-2023 V4.01 粤ICP备10103342号-1 更新RSS列表