下面这段代码在TForm1.Button1Click添上你的qq号,运行如果一秒内不动键盘鼠标就关掉qq<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Button2: TButton;<br> procedure Button1Click(Sender: TObject);<br> procedure Button2Click(Sender: TObject);<br> procedure FormCreate(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br> hhk,shwnd,HT:Thandle;<br> i:integer;<br><br>function hookproc(ncode:integer;wparam:wparam;lparam:lparam):LRESULT;stdcall;<br>procedure timerproc(hwnd,msg,ht,time:integer);stdcall;<br>implementation<br><br>{$R *.dfm}<br>procedure timerproc(hwnd,msg,ht,time:integer);stdcall;<br>begin<br> sendmessage(shwnd,WM_CLOSE,0,0);<br>end;<br><br>function hookproc(ncode:integer;wparam:wparam;lparam:lparam):LRESULT;stdcall;<br>begin<br> if i=0 then<br> SetTimer(form1.Handle,HT,1000,@timerproc)<br> else begin<br> KillTimer(form1.Handle,HT);<br> SetTimer(form1.Handle,HT,1000,@timerproc);<br> end;<br> i:=i+1;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> shwnd:=findwindow(nil,你的qq号码);<br> if hhk=0 then<br> hhk:=SetWindowsHookEx(WH_JOURNALRECORD,@hookproc,0,0);<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br> if hhk<>0 then<br> begin<br> UnHookWindowsHookEx(hhk);<br> hhk:=0;<br> end;<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> hhk:=0;<br> i:=0;<br>end;<br><br>end.