PC Review


Reply
 
 
Smithers
Guest
Posts: n/a
 
      17th Dec 2006
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.


 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      17th Dec 2006
"Smithers" <(E-Mail Removed)> 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/>

 
Reply With Quote
 
wyw
Guest
Posts: n/a
 
      18th Dec 2006
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

"Smithers" <(E-Mail Removed)> wrote in message
news:ODs%(E-Mail Removed)...
> 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.
>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      18th Dec 2006
"Paul" <(E-Mail Removed)> 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/>
 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      18th Dec 2006
"wyw" <(E-Mail Removed)> 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/>
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto logoff =?Utf-8?B?UnVkeQ==?= Microsoft Dot NET 1 10th Mar 2007 06:24 PM
auto logoff K Olsen Microsoft Windows 2000 New Users 0 17th Apr 2004 06:09 AM
Auto Logoff John M. Brown Microsoft Windows 2000 Group Policy 2 25th Feb 2004 07:37 PM
XP Auto Logoff Will Denny Windows XP General 2 1st Feb 2004 05:19 PM
Auto logoff PawelR Microsoft C# .NET 5 15th Oct 2003 05:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:43 PM.