Auto Logoff

S

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.
 
W

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
 
O

Otis Mukinfus

What you sent would probably work for an ASP.NET application, but not for a
windows application ;o)

[snip]
WYW

Smithers said:
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.
Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
 

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