0

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.

user223541
  • 1,265
  • 7
  • 19
  • 31

5 Answers5

2

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
  • 81,643
  • 20
  • 123
  • 127
2

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
  • 2,727
  • 1
  • 23
  • 27
  • 4
    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 Dec 03 '09 at 09:22
2

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

o.k.w
  • 25,490
  • 6
  • 66
  • 63
2

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
  • 15,870
  • 5
  • 45
  • 60
  • 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 Dec 03 '09 at 10:04
  • Using a factory means you could also create robot arms that do other environment saving activities. Brilliant. – Tom Duckering Dec 03 '09 at 10:24
  • 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 Dec 03 '09 at 10:33
0

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
  • 54,264
  • 27
  • 148
  • 161