We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

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

DReade83
DReade83 asked
on
Medium Priority
2,254 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.
Comment
Watch Question

Top Expert 2009
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Top Expert 2007

Commented:
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?

Author

Commented:
OK, what about Flex or Flash? Isn't that classed as a client-side application? Could that do the same thing as ActiveX?
Top Expert 2007

Commented:
Ah, it's all about the client. Sorry for my lizard-brain idea...Ajax will be of no use here...
Top Expert 2009
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Ah well, thanks man for your help, highly appreciated!
Top Expert 2009

Commented:
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").
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 https://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_24300306.html
Top Expert 2009

Commented:
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.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.