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.

regards,
KS


============
Declarations
============

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

====
Code
====

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
DoEvents
End If
If Timer - t >= TimeOut_InSec Then Exit Do
Loop
If bCancel = False Then MsgBox "Process idle is for " & Timer - t & " sec."
End Sub