Results 1 to 3 of 3

Thread: [RESOLVED] Track Application Idle time in VB

  1. #1

    Thread Starter
    Hyperactive Member Jenova's Avatar
    Join Date
    Feb 2006
    Location
    Googleplex
    Posts
    413

    Resolved [RESOLVED] Track Application Idle time in VB

    Hi there,

    I was wandering if there was a way i could track the idle time in my application. By idle i mean if the user has not interacted with my application for x amount of minutes. I basically need to find that out and the unload the program if it has ben left for 5 seconds.

    Any ideas??

    Thanks

    Jenova

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Track Application Idle time in VB

    One way would be:
    VB Code:
    1. Private Sub Form_KeyPress(KeyAscii As Integer)
    2.     Timer1.Enabled = False: Timer1.Enabled = True
    3. End Sub
    4.  
    5. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    6.     Timer1.Enabled = False: Timer1.Enabled = True
    7. End Sub
    8.  
    9. Private Sub Timer1_Timer()
    10.     Unload Me
    11. End Sub
    the form's KeyPreview property needs to be set to true.

    That will only work well if you have a lot of the form exposed (i.e. not covered with controls so the MouseMove event doesn't fire).

    Alternatively you could use GetCursorPos API on a timer to check the mouse position.

  3. #3

    Thread Starter
    Hyperactive Member Jenova's Avatar
    Join Date
    Feb 2006
    Location
    Googleplex
    Posts
    413

    Re: Track Application Idle time in VB

    Thats great. Thanks alot Bush Mobile

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