Solved

Can JavaScript detect when the PC is locked or the screensaver activates?

Posted on 2009-07-03
9
1,484 Views
Last Modified: 2012-05-07
I'm writing an application at the moment - an alert system for the company website, in the form of a popup window that sits in the background, updating every few seconds and tells the user if a new alert is generated. What I would like to do is somehow detect when the user locks their screen or the screensaver appears (idle timeout of 20 minutes).

Basically alerts would appear in this popup window, but if the users locks their screen or the screensaver appears, we want to re-route alerts to email instead, as staff have Windows Mobile devices.

Does anyone know if any of this is possible? Could JavaScript do this, or jQuery, or would I have to use something else?

We're using Windows XP SP3 site-wide and IE7 only.

Any help appreciated.

Thanks in advance.
0
Comment
Question by:DReade83
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
ID: 24774754
The short answer is: no, you cannot do that.
The longer answer is: you cannot do that because javascript does not have any rights on the underlying system, the same way you can never save a file without user interaction on a client's machine, or change his clock or security settings.

The even longer answer is: you can do that, but then you need to write your own plugin for Firefox, Opera, Safari, Chrome and an Add-On or ActiveX control for Internet Explorer. You'll then have to instruct your users to install this plugin and from then on, you can access just about everything you want. But the question then is: would you users trust you well enough to allow installation of a plugin that potentially harms their computer or opens a security hole? I can't judge that for you, but because you say that you only have to code for IE7 and Windows-based systems, you may just stick with ActiveX or Browser Extensions (not sure if extensions can do this, or even an ActiveX, they still operate under the security of the browser) or an Add-On.

It will cost significant time to write something like that. Sorry that I don't have better news for you.

-- Abel --
0
 
LVL 29

Expert Comment

by:Badotz
ID: 24774916
If the client can poll a process on the server (using Ajax) that in turn checks for the screensaver being active (can anything do that?) then I see no reason why such a scenario would not work for you.

It would take some development, to be sure, but then, what doesn't?

Or am I missing something impossible here?
0
 

Author Comment

by:DReade83
ID: 24774924
OK, what about Flex or Flash? Isn't that classed as a client-side application? Could that do the same thing as ActiveX?
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 29

Expert Comment

by:Badotz
ID: 24774930
Ah, it's all about the client. Sorry for my lizard-brain idea...Ajax will be of no use here...
0
 
LVL 39

Assisted Solution

by:abel
abel earned 500 total points
ID: 24774969
No, Flex of Flash are designed as general purpose plugins. Yes, they can do more then HTML + JS. No, they cannot access your system in any way. A flash, silverlight or flex application must run in the browser context. No user would install or trust Flash anymore if any malicious user building a website could access any information on the computer outside the browser context.

Flash can run standalone and it can have an elavated privilege, just as javascript can have an elavated privilege. The user gets a security warning, something along the lines "do you trust this page to allow it to access security sensitive data on your system? Click yes or no".

But, just accessing something on the system is one thing. Monitoring a system in realtime and asynchronously sending that data back is another thing (HTTP is stateless and never meant for keeping connections alive, it is not even possible, but with some tricks, like with AJAX, you can simulate that behavior).

-- Abel --
0
 

Author Comment

by:DReade83
ID: 24774977
Ah well, thanks man for your help, highly appreciated!
0
 
LVL 39

Expert Comment

by:abel
ID: 24775024
You're welcome, glad you appreciate it (most askers hate it when you have to tell them bad news or "it can't be done").
0
 
LVL 2

Expert Comment

by:ChrisDrake
ID: 24946434
These answers all sound wrong.
Your app runs on PCs, so can be written as a hypertext application (.HTA) - which can use VBScript instead of JavaScript, which *can* detect the screensaver in a number of different ways.

See http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_24300306.html
0
 
LVL 39

Expert Comment

by:abel
ID: 24949449
HTA does not have this power when served in a web page, unless the user explicitly grands it. Otherwise, visiting a certain web page with HTA would open up your system to anyone who wants. Though it is a tempting idea. But if you serve HTA you can also serve any of the other suggestions.

Why would "all these answers" be wrong? You can always write a plugin. No, you cannot access the system without user consent from a web page, HTA or otherwise and no, you cannot access your system with a flash or flex script.
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question