form1上添加timer1,label1 Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Type POINTAPI x As Long y As Long End TypePrivate t As DoublePrivate Sub Form_Load()
Timer1.Interval = 1000 End SubPrivate Sub Timer1_Timer()
Static lpCursorPos As POINTAPI Dim lpPoint As POINTAPI
GetCursorPos lpPoint If lpPoint.x <> lpCursorPos.x Or lpPoint.y <> lpCursorPos.y Then
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End TypePrivate t As DoublePrivate Sub Form_Load()
Timer1.Interval = 1000
End SubPrivate Sub Timer1_Timer()
Static lpCursorPos As POINTAPI
Dim lpPoint As POINTAPI
GetCursorPos lpPoint
If lpPoint.x <> lpCursorPos.x Or lpPoint.y <> lpCursorPos.y Then
lpCursorPos.x = lpPoint.x
lpCursorPos.y = lpPoint.y
t = Timer
Label1.Caption = "0"
Else
Label1.Caption = CStr(Int(Timer - t))
End If
End Sub
大家不要忘了这点考虑到查询系统半夜也许不开,可以忽略。