views:

83

answers:

2

I need to detect if the is no user activity in the system (e.g. what screensaver does) - all from a web browser.

As far as i'm aware it is not achievable using pure JavaScript. There is a library for detective idle input within a browser though: jquery-idletimer-plugin

For system idle events I'm thinking ActiveX control or SilverLight.

Has anybody done this before? Any recommendations?

UPDATE: I think a sensible solution would be to have a helper app that's running on user's computer and sends idle events to the browser. So the new question is how can i send a message to an open browser (webkit based, with my web app open) from a Windows app so that it can be picked up from JavaScript?

+3  A: 

There won't be any reliable way of doing this ever. As Denis said you can't do it with Silverlight and ActiveX works only in Internet Explorer, so in case this is a crucial part of your application then you should better have some really good reasons for me to use it, otherwise why should I start up IE(and a machine with Windows on it in my case)?

Hell, even if I would be using IE, why should I open up a site that's monitoring the activity OUTSIDE of my browser? Who's telling me that you're not logging my keystrokes at the same time, huh?

There's no good reason on this planet for doing such a thing from within a Browser, you're essentially destroying all the trust in your application by circumventing the Browser's security model. The sandbox is there for good reasons, otherwise surfing the web would be just as dangerous as downloading random files and executing them...

So whatever you're trying to achieve with this, please give up on it and search for a better solution that A: Works cross browser/platform and B: Doesn't make your App look like it could steal my passwords any day.

Ivo Wetzel
Do you use Linux? ;)
Delan Azabani
Indeed I do, only have a Win7 Starter install on my Netbook and man I tell you it's hell... but Ubuntu on the Netbook runs just great ;)
Ivo Wetzel
Thanks for your response. I do understand all the security and technological implications of this. My scenarion is a web-based time tracking tool. Activity tracking outside the browser is totally optional and of course will only work on IE with ActiveX. So, looks like it's not worth doing it anyway.
Muxa
I have updated the question with a new idea that'll make the system more secure.
Muxa
+1  A: 

If you really need to this, (I'm hoping its for a client who asked for a feature like this) you should write your own browser (C# allows you to just drop a web browser control on a form with only a little customization needed) and have your users use that browser (which you can then use to detect idle status using the operating system features.

Again this is under the assumption that you have a client that asked for this and not for a project that will be out in the wild, otherwise what Ivo said is completely true, I wouldn't want to download a brand new browser just to run a simple website.

James J. Regan IV
It does seem a to be a good option. I'd go for webkit though - I don't need a full browser - just a desktop app that runs my web app and adds some extra functionality. I wonder if Titanium would be a good alternative.
Muxa
I have updated the question with a new idea that'll hopefully make the system more secure.
Muxa
I think you misunderstood what I meant. I meant not using a standard browser at all but showing everything in this other desktop application, then you can just change the HTML of the browser control (if using C#) using the idle detection code as if it was being done using javascript.
James J. Regan IV