鼠标、键盘3分钟不操作时,运行VB程序

来源:百度知道 编辑:UC知道 时间:2024/06/07 14:45:13
想做一个.exe程序,实现下面命令。
Private Sub Form_Load()
Form1.show
end sub
很简单吧,就是想显示Form1而已。
但有个条件:当鼠标、键盘3分钟不操作时,才显示。
屏保代码一大堆,哪部分是当鼠标、键盘不操作时运行程序的?
本人菜鸟,给说详细点儿

Private Type POINTAPI
X As Long
Y As Long
End Type
Dim LastPoint As POINTAPI
Dim LastActTime as Date
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Private Sub Form_Load()'启动窗体
LastActTime=Now
Timer1.Enabled=True
Timer1.Interval=1000
Me.Hide
End Sub

Private sub Timer1_Timer()
Dim CurrentPoint as POINTAPI
Dim nKeyCode as Long
Dim Ret as Long

Call GetCursorPos(CurrentPoint)'获取当前鼠标位置
If CurrentPoint.X <> LastPoint.X Or CurrentPoint.Y <> LastPoint.Y Then '判断是否有移动鼠标
LastPoint = CurrentPoint
LastActTime = Now
End If
For nKeyCode = 1 To 256 '判断是否有按动键盘
ret = GetAsyncKeyState(nKeyCode)
If ret <> 0 Th