Hola, con la api llamada
GetQueueStatus podes saber el tiempo inactivo...un ejemplo que se cierra despues de 5 segundos de inactividad..
Código vb:
Ver originalOption Explicit
Private Declare Function GetQueueStatus Lib "user32" (ByVal fuFlags As Long) As Long
Private Const QS_KEY = &H1
Private Const QS_MOUSEMOVE = &H2
Private Const QS_MOUSEBUTTON = &H4
Private Const QS_MOUSE = (QS_MOUSEMOVE Or QS_MOUSEBUTTON)
Private Const QS_INPUT = (QS_MOUSE Or QS_KEY)
Public bCancel As Boolean
Public Sub Inactividad(ByVal TimeOut_InSec As Long)
Dim t As Long
t = Timer
Do While bCancel = False
If GetQueueStatus(QS_INPUT) Then
t = Timer
DoEvents
End If
If Timer - t >= TimeOut_InSec Then Exit Do
Loop
If bCancel = False Then MsgBox "La Aplicacion se cerro despues de " & Timer - t & " segundos inactiva": Unload Me
End Sub
Private Sub Form_Load()
Me.Show
Call Inactividad(5)
End Sub
Private Sub Form_Unload(Cancel As Integer)
bCancel = True
End Sub
saludos.