Private Declare Function GetLastInputInfo Lib "user32" (plii As LASTINPUTINFO) As Boolean
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Type LASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
Dim lii As LASTINPUTINFO
Private Sub Form_Load()
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Dim mytime As Double
lii.cbSize = Len(lii)
GetLastInputInfo lii
mytime = GetTickCount - lii.dwTime
Debug.Print mytime & "ms"
If mytime \ 1000 > 10 Then Unload Me '如果超过十秒就关闭
End Sub
---------------------
VB中其它进程可用上面的代码,抄自tztz520所写,2K以上系统运行。