Exit VB program if user idle in a period of time
Greetings to all,
I'm using "GetQueueStatus" function to check user idle in a period of time.
My VB program seem like hang if go to other program, and then come back to
VB program. This is because I'm using Do...Loop statement causing the program
running non-stop I'm suspecting. But if I don't loop, I can't check user
idle in a period of time. I called "CheckInputIdle" subroutine in Form_Activate().
Do you have any suggestion? Below are my codes.
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 CheckInputIdle(ByVal TimeOut_InSec As Long)
Dim t As Long
t = Timer
Do While bCancel = False
If GetQueueStatus(QS_INPUT) Then
t = Timer
If Timer - t >= TimeOut_InSec Then Exit Do
If bCancel = False Then MsgBox "Process idle is for " & Timer - t & " sec."
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center