[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
Re: Track Application Idle time in VB
One way would be:
VB Code:
Private Sub Form_KeyPress(KeyAscii As Integer)
Timer1.Enabled = False: Timer1.Enabled = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Enabled = False: Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Unload Me
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.
Re: Track Application Idle time in VB
Thats great. Thanks alot Bush Mobile :)