Results 1 to 11 of 11

Thread: How to check the idle time? (RESOLVED)

  1. #1

    Thread Starter
    Addicted Member AlvaroF1's Avatar
    Join Date
    Sep 2002
    Location
    SP - Brazil
    Posts
    200

    Question How to check the idle time? (RESOLVED)

    I used to use the following code to check the idle time on VB6:

    VB Code:
    1. Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    2. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    3. Private Type POINTAPI
    4.     x As Long
    5.     y As Long
    6. End Type
    7. Private Sub Timer1_Timer()
    8.     Static lNotActive As Long
    9.     Static LastCursorPos As POINTAPI
    10.     lNotActive = lNotActive + 1
    11.     GetCursorPos CursorPos
    12.     If (CursorPos.x <> LastCursorPos.x) Or (CursorPos.y <> LastCursorPos.y) Then
    13.         LastCursorPos = CursorPos
    14.         lNotActive = 0
    15.     Else
    16.         For lCounter = 0 To 255
    17.             If GetAsyncKeyState(lCounter) > 0 Then lNotActive = 0
    18.         Next
    19.     End If
    20.     If lNotActive = 180 Then MsgBox "Idle time reached!"
    21. End Sub

    What about using VB. NET?


    Thank you.
    Last edited by AlvaroF1; Sep 14th, 2003 at 05:02 PM.

  2. #2
    Lively Member
    Join Date
    May 2002
    Posts
    94
    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?

  3. #3

    Thread Starter
    Addicted Member AlvaroF1's Avatar
    Join Date
    Sep 2002
    Location
    SP - Brazil
    Posts
    200
    Sorry if I wasn't clear.

    Yes, I'd like to check the system's idle time.


    Thanks.

  4. #4
    Lively Member
    Join Date
    May 2002
    Posts
    94

    Enjoy

    Heres your conversion

    Please Edit your inital Message Subject to [Resolved] if this Solved your Problem.

    VB Code:
    1. Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Integer
    2.  
    3.   Public Sub Timer1_Timer()
    4.     Static lNotActive As Long
    5.     Static LastCursorPos As System.Drawing.Point
    6.     Dim CursorPos As System.Drawing.Point
    7.  
    8.     lNotActive = lNotActive + 1
    9.     CursorPos = System.Windows.Forms.Cursor.Current.Position
    10.  
    11.     If (CursorPos.X <> LastCursorPos.X) Or (CursorPos.Y <> LastCursorPos.Y) Then
    12.       LastCursorPos = CursorPos
    13.       lNotActive = 0
    14.     Else
    15.       Dim lCounter As Integer
    16.       For lCounter = 0 To 10
    17.         If GetAsyncKeyState(lCounter) > 0 Then lNotActive = 0
    18.       Next
    19.     End If
    20.     If lNotActive = 180 Then MsgBox("Idle time reached!")
    21.   End Sub

  5. #5
    Lively Member
    Join Date
    May 2002
    Posts
    94
    Bump

  6. #6

    Thread Starter
    Addicted Member AlvaroF1's Avatar
    Join Date
    Sep 2002
    Location
    SP - Brazil
    Posts
    200
    Allright!

    Thanks for your help.

  7. #7
    Addicted Member Codehammer's Avatar
    Join Date
    Aug 2004
    Posts
    164

    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

  8. #8
    Lively Member
    Join Date
    May 2002
    Posts
    94
    Yes, it should. test it out.
    If your post is resolved, mark it as such using the thread tools, Keep the forums tidy.

  9. #9
    Addicted Member Codehammer's Avatar
    Join Date
    Aug 2004
    Posts
    164

    Re: How to check the idle time? (RESOLVED)

    Quote 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

  10. #10
    Addicted Member Codehammer's Avatar
    Join Date
    Aug 2004
    Posts
    164

    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

  11. #11
    Addicted Member Codehammer's Avatar
    Join Date
    Aug 2004
    Posts
    164

    Re: How to check the idle time? (RESOLVED)

    Quote 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
  •  



Click Here to Expand Forum to Full Width