views:

100

answers:

5

hi, I want to write a program in java such that as soon as the computer is locked by pressing (ALT +CTR+DEL -> lock comp ) the monitor becomes off.I want to implement this is java.

Also when user presses any key of keyboard the monitor shold be on.

How can i do this?

I want to save the electricity by doing this and make save environment.

+2  A: 

That is a function that is already implemented by your operating system. It’s tied in so deeply with operation system and hardware dependent functions that it’s impossible to in pure Java, anyway.

Bombe
+2  A: 

Set your screen saver and energy saving settings and be done with.

In the time saved not writing this in Java you can do some recycling :o)

Tom Duckering
i want to do it in java only
Sorry, let me clarify. Set your screensaver and energy saving settings by hand and then you don't write any code. By all means write no code in Java. I prefer writing no code in Objective-C.
Tom Duckering
+3  A: 

It'll be easier to do this:
ALT+CTR+DEL -> lock comp -> Press monitor power switch.

o.k.w
And even easier to do this: WIN+L -> Press monitor power switch.:-p
Adriaan Koster
A: 

As others said, don't use Java.

If you use Windows, you might want to have a look at the monitor off and lockws commands of NirCmd.

Peter Lang
+2  A: 

You could build a cool robot arm, controlled by a Java program, which presses the monitor button for you. Check out http://mindstorms.lego.com

Adriaan Koster
only fools do that.I guess u are one among them
I'd definitely go for the robot arm approach. Certainly seems the most practical and pragmatic way forward (don't know why people are suggesting using the screensaver - madness!). But why stop there? You should follow good Java practice and create a RobotArmFactory class.
Nick Pierpoint
Using a factory means you could also create robot arms that do other environment saving activities. Brilliant.
Tom Duckering
I see where you're coming from. I suppose my RobotArmFactory suggestion is a little restrictive. What we really need is a way to mass-produce robot arms capable of a range of activities - a RobotArmFactoryFactory. Nice.
Nick Pierpoint