Catch any event in the program

S

Samuel

Hi

I would like to keep resetting a timer for auto logout system. For that I
need to know whenever any event happen like opening a new window, clicking
on a button so I can reset the timer for the auto logout.

However I will have to filter out some event like timers event so I guess
that I need to know about events that are triggered by the user only

Thank you,
Samuel
 
M

molafish

You can try cathing all MouseDown events and see if they are on any of
your open forms. Within that event, you can set some global variable
that your auto logout timer will see and consequently not log out.

On your master form:
Private WithEvents mf As MouseDownHandler.MouseDownMessageFilter

Private Sub mf_MouseDown() Handles mf.MouseDown
If Form.ActiveForm Is myForm Then
globalVariableSignifyingActivity += 1
End If
End Sub

You would just amend that myForm variable to a list of all your forms:
If Form.ActiveForm Is myForm or Form.ActiveForm Is thatForm Then
 
A

Armin Zingler

Samuel said:
Hi

I would like to keep resetting a timer for auto logout system. For
that I need to know whenever any event happen like opening a new
window, clicking on a button so I can reset the timer for the auto
logout.
However I will have to filter out some event like timers event so I
guess that I need to know about events that are triggered by the user
only


Try
http://msdn.microsoft.com/en-us/library/system.windows.forms.application.addmessagefilter.aspx

Though, you don't get mouse messages outside your application. A better way
may be calling GetLastInputInfo
(http://msdn.microsoft.com/en-us/library/ms646302.aspx) every yx seconds.
Subtract it from environment.tickcount to get the input idle time.



Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top