寻求VB小工具源码

来源:百度知道 编辑:UC知道 时间:2024/06/05 09:21:22
我要挂一个软件,但是他会监视鼠标状态.

如果鼠标超过多长时间,软件就会自动停止

我需要一个可以设置已秒做单位的时间限制

在N的时间情况下,鼠标在屏幕上晃几圈.,

然后再继续倒计时.在动鼠标.

死循环

'在窗体上分别放置一个 TextBox、Label、Timer 控件,都使用默认属性
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Dim ctT As Long, ctT1 As Long, ctX As Long, ctY As Long

Private Sub Form_Load()
Text1.Text = "10 秒"
Timer1.Interval = 1000: Timer1.Enabled = True
Call Timer1_Timer
End Sub

Private Sub Text1_Change()
ctT = Val(Text1.Text)
Me.Caption = "超过 " & ctT & " 秒未移动鼠标,程序会自动停止"
ctT1 = ctT
End Sub

Private Sub Timer1_Timer()
'获取鼠标指针的当前位置
Dim XY As POINTAPI, dl As Long

dl = GetCursorPos(XY)

If ctX = XY.x And ctY = XY.y Then
ctT1 = ctT1 - 1 '鼠标没有动
Else
ctT1 = ctT '鼠标移动了,重新计时
End If

ctX = XY.x: ctY = XY.y

If ctT1 < 1 Then