|
-
Sep 14th, 2003, 09:43 AM
#1
Thread Starter
Addicted Member
How to check the idle time? (RESOLVED)
I used to use the following code to check the idle time on VB6:
VB Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Timer1_Timer()
Static lNotActive As Long
Static LastCursorPos As POINTAPI
lNotActive = lNotActive + 1
GetCursorPos CursorPos
If (CursorPos.x <> LastCursorPos.x) Or (CursorPos.y <> LastCursorPos.y) Then
LastCursorPos = CursorPos
lNotActive = 0
Else
For lCounter = 0 To 255
If GetAsyncKeyState(lCounter) > 0 Then lNotActive = 0
Next
End If
If lNotActive = 180 Then MsgBox "Idle time reached!"
End Sub
What about using VB. NET?
Thank you.
Last edited by AlvaroF1; Sep 14th, 2003 at 05:02 PM.
-
Sep 14th, 2003, 12:47 PM
#2
Lively Member
Can you explaine with a little more detail?
Do you want to create a timer, or do you want to check the system's Idle time like you would for a screensaver?
Is this Idle Time, application or system wide?
-
Sep 14th, 2003, 01:04 PM
#3
Thread Starter
Addicted Member
Sorry if I wasn't clear.
Yes, I'd like to check the system's idle time.
Thanks.
-
Sep 14th, 2003, 01:45 PM
#4
Lively Member
Enjoy
Heres your conversion
Please Edit your inital Message Subject to [Resolved] if this Solved your Problem.
VB Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Integer
Public Sub Timer1_Timer()
Static lNotActive As Long
Static LastCursorPos As System.Drawing.Point
Dim CursorPos As System.Drawing.Point
lNotActive = lNotActive + 1
CursorPos = System.Windows.Forms.Cursor.Current.Position
If (CursorPos.X <> LastCursorPos.X) Or (CursorPos.Y <> LastCursorPos.Y) Then
LastCursorPos = CursorPos
lNotActive = 0
Else
Dim lCounter As Integer
For lCounter = 0 To 10
If GetAsyncKeyState(lCounter) > 0 Then lNotActive = 0
Next
End If
If lNotActive = 180 Then MsgBox("Idle time reached!")
End Sub
-
Sep 14th, 2003, 04:28 PM
#5
Lively Member
-
Sep 14th, 2003, 05:01 PM
#6
Thread Starter
Addicted Member
Allright!
Thanks for your help.
-
Sep 17th, 2004, 01:51 AM
#7
Addicted Member
What About keystrokes
Will This Monitor keystrokes Too, As Pasrt of Idle Time.
What if the Dude is in work and not Mousing around?
Curiosity SKILLED the cat
Google Talk from your Mobile phone
Chat from your mobile or get an emulator like J2ME Wireless Toolkit 2.2
-
Sep 17th, 2004, 12:39 PM
#8
Lively Member
Yes, it should. test it out.
If your post is resolved, mark it as such using the thread tools, Keep the forums tidy.
-
Dec 8th, 2004, 01:00 AM
#9
Addicted Member
Re: How to check the idle time? (RESOLVED)
 Originally Posted by Evad
Yes, it should. test it out.
NO IT DOESNT, TRIED IT 5 MIN. Ago
Curiosity SKILLED the cat
Google Talk from your Mobile phone
Chat from your mobile or get an emulator like J2ME Wireless Toolkit 2.2
-
Jan 10th, 2005, 09:07 AM
#10
Addicted Member
Re: How to check the idle time? (RESOLVED)
How can One Use the System Idle Process - Its there when you press CTRL+ALT+DEL.
Curiosity SKILLED the cat
Google Talk from your Mobile phone
Chat from your mobile or get an emulator like J2ME Wireless Toolkit 2.2
-
Feb 7th, 2005, 01:22 AM
#11
Addicted Member
Re: How to check the idle time? (RESOLVED)
 Originally Posted by Codehammer
How can One Use the System Idle Process - Its there when you press CTRL+ALT+DEL.
Examining the Code, its only Checking for a mousemove event, the Program Will Work if I use a Txtchanged even, but only if the program is in Focus.
Any Ideas
Curiosity SKILLED the cat
Google Talk from your Mobile phone
Chat from your mobile or get an emulator like J2ME Wireless Toolkit 2.2
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
|
Click Here to Expand Forum to Full Width
|