Jared,
First off mouse and key messages comes through the windows message loop. In
this case you can use message filter to handle all mouse and keyboard
message globally for the whole application. Look at
Application.AddMessageFilter.
Secondly it depends on your definition on user inactivity. Is it just not
working wiht the application or is just not using that particular
application? In the latter case you can use message filters as I suggested
earlier in the former you have no managed solution. You should resort do
native API GetLastInputInfo (min req Win2K)
Third option is to use low level keyboard and mouse hookd which requirese
PInvoke again.
--
HTH
Stoitcho Goutsev (100)
"Jared" <ja***@paradigmitz.net.au> wrote in message
news:uk**************@TK2MSFTNGP12.phx.gbl...
As for key events, MDIParent.KeyPreview = true
Not sure if this would have to be done for all forms?
Yes, I was thinking of using a timer.
"Jeff S" <A@B.COM> wrote in message
news:uT*************@TK2MSFTNGP15.phx.gbl... Hummm, MousePosition is a property. How would I use that to determine if
there has been any user activity? Are you suggesting that I periodically
check the mouse coordinates? Not sure that would work for all scenarios -
like if the user is simply typing and not moving the mouse, or if they
have multiple MDI child windows open, then I'd have to have complicated
logic that determines which is the active one... But it might be part of
a solution...
-Jeff
"Jared" <ja***@paradigmitz.net.au> wrote in message
news:em**************@TK2MSFTNGP09.phx.gbl... Hi,
I would try to use
system.Windows.Forms.Form.ActiveForm.MousePosition
"Jeff S" <A@B.COM> wrote in message
news:eU**************@TK2MSFTNGP09.phx.gbl...
I'm creating a new Windows Forms MDI application...
How can I add cause the application to shut itself down after a period
of [no user activity]?
I did this in an old COM/VB6 application and I had to have code behind
practically all visible UI controls (triggered on the Mouse_Move event)
that reset a global variable monitored by a timer. If the global value
incremented past a certain point, then a Timer event procedure would
cause a dialog to appear. If the user failed to respond to the dialog
after 10 seconds, then the app would shut down.
Does .NET give us an easier way to accomplish the same? I don't want to
have to detect the mouse_move event of practically every UI control and
have a timer running in the background the whole time, if possible.
Thanks!