我任何点击鼠标,如何获得鼠标点击间隔的时间(毫秒)?在线等待....(50分)

  • 主题发起人 主题发起人 ymkj
  • 开始时间 开始时间
Y

ymkj

Unregistered / Unconfirmed
GUEST, unregistred user!
我任何点击鼠标,如何获得鼠标点击间隔的时间,因为鼠标点击的时间很短,取到的间隔时间应该是毫秒数,求助!!
 
gettickcount
 
用getLocalTime取得連續的兩個時間﹐相減
 
我试一下,OK就给分,多谢
 
unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs, AppEvnts, StdCtrls;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; ApplicationEvents1: TApplicationEvents;<br>&nbsp; &nbsp; Memo1: TMemo;<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; procedure ApplicationEvents1Message(var Msg: tagMSG;<br>&nbsp; &nbsp; &nbsp; var Handled: Boolean);<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br>&nbsp; s: integer = -1;<br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;<br>&nbsp; var Handled: Boolean);<br>var<br>&nbsp; n: integer;<br>begin<br>&nbsp; case msg.message of<br>&nbsp; &nbsp; WM_LBUTTONDOWN, WM_RBUTTONDOWN:<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; if s &lt; 0 then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s := gettickcount;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; n := gettickcount;<br>&nbsp; &nbsp; &nbsp; &nbsp; Memo1.Lines.Add(format('%d毫秒', [n - s]));<br>&nbsp; &nbsp; &nbsp; &nbsp; s := n;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; end;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; i: integer;<br>begin<br>&nbsp; for i := 1 to 100 do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; sleep(50);<br>&nbsp; &nbsp; &nbsp; Application.ProcessMessages ;<br>&nbsp; &nbsp; &nbsp; mouse_event(MOUSEEVENTF_LEFTDOWN, 100, 100, 0, 0);<br><br>&nbsp; &nbsp; end;<br>end;<br><br>end.<br><br><br><br>object Form1: TForm1<br>&nbsp; Left = 192<br>&nbsp; Top = 107<br>&nbsp; Width = 544<br>&nbsp; Height = 375<br>&nbsp; Caption = 'Form1'<br>&nbsp; Color = clBtnFace<br>&nbsp; Font.Charset = DEFAULT_CHARSET<br>&nbsp; Font.Color = clWindowText<br>&nbsp; Font.Height = -11<br>&nbsp; Font.Name = 'MS Sans Serif'<br>&nbsp; Font.Style = []<br>&nbsp; OldCreateOrder = False<br>&nbsp; PixelsPerInch = 96<br>&nbsp; TextHeight = 13<br>&nbsp; object Memo1: TMemo<br>&nbsp; &nbsp; Left = 351<br>&nbsp; &nbsp; Top = 0<br>&nbsp; &nbsp; Width = 185<br>&nbsp; &nbsp; Height = 348<br>&nbsp; &nbsp; Align = alRight<br>&nbsp; &nbsp; Lines.Strings = (<br>&nbsp; &nbsp; &nbsp; 'Memo1')<br>&nbsp; &nbsp; ScrollBars = ssVertical<br>&nbsp; &nbsp; TabOrder = 0<br>&nbsp; end<br>&nbsp; object Button1: TButton<br>&nbsp; &nbsp; Left = 136<br>&nbsp; &nbsp; Top = 208<br>&nbsp; &nbsp; Width = 75<br>&nbsp; &nbsp; Height = 25<br>&nbsp; &nbsp; Caption = '自动1000次'<br>&nbsp; &nbsp; TabOrder = 1<br>&nbsp; &nbsp; OnClick = Button1Click<br>&nbsp; end<br>&nbsp; object ApplicationEvents1: TApplicationEvents<br>&nbsp; &nbsp; OnMessage = ApplicationEvents1Message<br>&nbsp; &nbsp; Left = 224<br>&nbsp; &nbsp; Top = 160<br>&nbsp; end<br>end<br>
 
后退
顶部