unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, AppEvnts, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> ApplicationEvents1: TApplicationEvents;<br> Memo1: TMemo;<br> Button1: TButton;<br> procedure ApplicationEvents1Message(var Msg: tagMSG;<br> var Handled: Boolean);<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br> s: integer = -1;<br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;<br> var Handled: Boolean);<br>var<br> n: integer;<br>begin<br> case msg.message of<br> WM_LBUTTONDOWN, WM_RBUTTONDOWN:<br> begin<br> if s < 0 then<br> begin<br> s := gettickcount;<br> exit;<br> end;<br><br> n := gettickcount;<br> Memo1.Lines.Add(format('%d毫秒', [n - s]));<br> s := n;<br> end;<br> end;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> i: integer;<br>begin<br> for i := 1 to 100 do<br> begin<br> sleep(50);<br> Application.ProcessMessages ;<br> mouse_event(MOUSEEVENTF_LEFTDOWN, 100, 100, 0, 0);<br><br> end;<br>end;<br><br>end.<br><br><br><br>object Form1: TForm1<br> Left = 192<br> Top = 107<br> Width = 544<br> Height = 375<br> Caption = 'Form1'<br> Color = clBtnFace<br> Font.Charset = DEFAULT_CHARSET<br> Font.Color = clWindowText<br> Font.Height = -11<br> Font.Name = 'MS Sans Serif'<br> Font.Style = []<br> OldCreateOrder = False<br> PixelsPerInch = 96<br> TextHeight = 13<br> object Memo1: TMemo<br> Left = 351<br> Top = 0<br> Width = 185<br> Height = 348<br> Align = alRight<br> Lines.Strings = (<br> 'Memo1')<br> ScrollBars = ssVertical<br> TabOrder = 0<br> end<br> object Button1: TButton<br> Left = 136<br> Top = 208<br> Width = 75<br> Height = 25<br> Caption = '自动1000次'<br> TabOrder = 1<br> OnClick = Button1Click<br> end<br> object ApplicationEvents1: TApplicationEvents<br> OnMessage = ApplicationEvents1Message<br> Left = 224<br> Top = 160<br> end<br>end<br>