Home All Groups Group Topic Archive Search About
Author
17 Dec 2006 9:39 AM
Smithers
Using .NET 2.0...
How can I cause Windows Forms application to shut itself down after a period
(say 15 minutes) of [no user activity]? Specifically, I'm wanting some
options for detecting that the user is somehow using the application (either
detect mouse clicks or keyboard input).

The idea is that if the user walks away from their computer and is gone for
an extended period, then the app will close itself down to help curb
malicious use.

This is a Windows Forms MDI app.

Thanks.

Author
17 Dec 2006 12:18 PM
Herfried K. Wagner [MVP]
"Smithers" <A@B.com> schrieb:
> How can I cause Windows Forms application to shut itself down after a
> period (say 15 minutes) of [no user activity]? Specifically, I'm wanting
> some options for detecting that the user is somehow using the application
> (either detect mouse clicks or keyboard input).

Check out this code for inspiration:

<URL:http://dotnet.mvps.org/dotnet/code/misc/#UserIdle>

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Are all your drivers up to date? click for free checkup

Author
18 Dec 2006 6:52 PM
Paul
Just wondering if this can be done with 1.1 as well?
--
Paul G
Software engineer.


Show quoteHide quote
"Herfried K. Wagner [MVP]" wrote:

> "Smithers" <A@B.com> schrieb:
> > How can I cause Windows Forms application to shut itself down after a
> > period (say 15 minutes) of [no user activity]? Specifically, I'm wanting
> > some options for detecting that the user is somehow using the application
> > (either detect mouse clicks or keyboard input).
>
> Check out this code for inspiration:
>
> <URL:http://dotnet.mvps.org/dotnet/code/misc/#UserIdle>
>
> --
>  M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
>
>
Author
18 Dec 2006 8:41 PM
Herfried K. Wagner [MVP]
"Paul" <P***@discussions.microsoft.com> schrieb:
> Just wondering if this can be done with 1.1 as well?

Yes, for sure.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
18 Dec 2006 8:12 PM
wyw
It is easy to implement it in client side using script.

It works like this:

(1) When the page OnLoad in client side, set a timeout to process it.

(2) capture mouse activity in this page and reset the timeout

Following is the javascript:

var tID = 0;

var IntTime;

function OnActive(page)

{

clearTimeout(tID);

tID = setTimeout("WindowIdle()", IntTime);

}

function OnPageLoad(page, timeout)

{

var body = page.document.body;


if (timeout > 0)

{

IntTime = timeout;

}

// reset the timeout when the page is active

body.onclick=OnActive;

body.onmousemove=OnActive;


tID = setTimeout("WindowIdle()", IntTime);

}

function WindowIdle()

{

// do whatever you want, usually redirect to another page

}

Hope it is useful.

WYW

Show quoteHide quote
"Smithers" <A@B.com> wrote in message
news:ODs%2308bIHHA.1248@TK2MSFTNGP02.phx.gbl...
> Using .NET 2.0...
> How can I cause Windows Forms application to shut itself down after a
> period (say 15 minutes) of [no user activity]? Specifically, I'm wanting
> some options for detecting that the user is somehow using the application
> (either detect mouse clicks or keyboard input).
>
> The idea is that if the user walks away from their computer and is gone
> for an extended period, then the app will close itself down to help curb
> malicious use.
>
> This is a Windows Forms MDI app.
>
> Thanks.
>
Author
18 Dec 2006 8:42 PM
Herfried K. Wagner [MVP]
"wyw" <yw***@globecommsystems.com> schrieb:
> It is easy to implement it in client side using script.

Hm...  The OP posted the question to the Windows Forms group ;-).

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>

Bookmark and Share