Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I m developing web application using ASP.NET and I want to close the current user session if the computer is idle for 5 minutes. Idle not means for web application only, Its full system that means if no keystroke received from keyboard for 5 mins.

I got some info thru Google about Idle Tracker in VC++ but I dont know how to use that DLL in my web application. Link here.

Please guide me how to achieve this. I want to get the total computer active time and idle time thru asp.net for my employees productivity report.

Regards
Arun.
8056171741.
Posted

First of all you need to understand the differences between a windows application and a web application. Tha VC++ library is for windows applications and can't be used by a web application.
To achive what you describe, you have to use javascript to track mouse move, and redirect the user to a logout script if the mouse doesn't move for a specific amount of time.

To track mouse movement using javascript is easy, and combined with a javascript timer, you can achive the functionality you are asking for. Everytime the mouse moves, you reset your timer. If your timer exceeds 5000 ms, then you redirect the user to a logout script.
 
Share this answer
 
Comments
Arunachalam Gurusamy 25-Apr-13 7:59am    
Thank you for your explanation about VC++ lib files. I have added one javascript file to track the keystroke but its worked only within the web page but i need through out the computer. Please suggest how to achieve this.

<%-- Script for idle mouse move and keypress --%>
<%--Add following id inside bodydiv <div class="maindiv" id="SecondsUntilExpire">--%>

<script type="text/javascript">
var IDLE_TIMEOUT = 10; //seconds
var _idleSecondsCounter = 0;
document.onclick = function() {
_idleSecondsCounter = 0;
};
document.onmousemove = function() {
_idleSecondsCounter = 0;
};
document.onkeypress = function() {
_idleSecondsCounter = 0;
};
window.setInterval(CheckIdleTime, 1000);

function CheckIdleTime() {
_idleSecondsCounter++;
var oPanel = document.getElementById("SecondsUntilExpire");
if (oPanel)
oPanel.innerHTML = (IDLE_TIMEOUT - _idleSecondsCounter) + "";
if (_idleSecondsCounter >= IDLE_TIMEOUT) {
alert("Time expired!");
document.location.href = "SessionExpired.aspx";
}
}
</script>
StianSandberg 25-Apr-13 8:01am    
There is absolutely no way you can monitor keystrokes or mouse movement outside your website on clients computer. And that's a good thing! Just imagine how that would be in the hands of the wrong people.
Thank you Alluvial,

ASP.Net is a bad choice for this requirement. ASP.Net runs on the server, but I want to track some client side events. For security reasons, a web page can't have such privileges without the use of ActiveX or browser plugin, but it's complex to write, complex to deploy and a big opened window to security breaches.

I understood the differences between a windows application and a web application. The VC++ library is for windows applications and can't be used by a web application.

There is a way to achieve this, I have to use javascript to track mouse move, and redirect the user to a logout script if the mouse doesn't move for a specific amount of time.

But There is absolutely no way I can monitor keystrokes or mouse movement outside the website on clients computer. And that's a good thing! Just imagine how that would be in the hands of the wrong people. So if its achievable also, it should not be encouraged.

So I m closing the question and have started the same task in WPF.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900