使用鼠标钩子函数可以搞定。
具体的你看看这篇文章http://www.huamin.com.cn/active/dispbbs.asp?boardid=4&rootid=130&id=130&star=

解决方案 »

  1.   

    unit main;interfaceuses
     Windows, Messages, SysUtils, Controls, StdCtrls;var
     nexthookproc:HHook;
     procsaveexit:Pointer;
     function KeyBoardHookHandler(icode:integer;wparam:wparam;lparam:lparam):lresult;stdcall;export;
     function setkeyhook:bool;export;//加载钩子
     function endkeyhook:bool;export;//卸载钩子
     procedure keyhookexit;far;const
     afilename='c:\debug.txt';//将键盘输入动作写入文件中var
     debugfile:textfile;implementationfunction KeyboardHookHandler(icode:integer;wparam,lparam:LongInt):LongInt;stdcall;export;
    begin
     if icode<0 then
      begin
       result:=callnexthookex(nexthookproc,icode,wParam,lParam);
       exit;
      end;
     assignfile(debugfile,afilename);
     append(debugfile);
     if GetKeyState(VK_Return)<0 then
      begin
       writeln(debugfile,'a');
       write(debugfile,char(wParam));
      end
     else
      write(debugfile,char(wParam));
      closefile(debugfile);
      result:=0;
     end;function setkeyhook:bool;export;
    begin
     nexthookproc:=SetWindowsHookEx(WH_Keyboard,keyboardhookhandler,hInstance,0);
     result:=true;
    end;function endkeyhook:bool;export;
    begin
     if nexthookproc<>0 then
      begin
       UnHookWindowsHookEx(nexthookproc);
       nexthookproc:=0;
       messagebeep(0);
      end;
     result:=true;
    end;procedure keyhookexit;far;
    begin
     if nexthookproc<>0 then endkeyhook;
     exitproc:=procsaveexit;
    end;
    end.================================================================CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!★  浏览帖子速度极快![建议系统使用ie5.5以上]。 ★  多种帖子实现界面。 
    ★  保存帖子到本地[html格式]★  监视您关注帖子的回复更新。
    ★  可以直接发贴、回复帖子★  采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录! 
    ★  支持在线检测程序升级情况,可及时获得程序更新的信息。★★ 签名  ●  
         可以在您的每个帖子的后面自动加上一个自己设计的签名哟。Http://www.ChinaOK.net/csdn/csdn.zip
    Http://www.ChinaOK.net/csdn/csdn.rar
    Http://www.ChinaOK.net/csdn/csdn.exe    [自解压]