|
-
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.
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks