Disabling Screen Saver / Hibernate Via Website

I am working on a web application that needs to be active on the monitor, sometimes for hours, without touching the computer.

The problem is that some computers have a screen saver, or worse, sleep mode while they are inactive.

I'm trying to think of a way around it. I was looking for java applets or maybe a flash file that does just that. I did not find anything, unfortunately.

I apologize for the too general question, but I'm pretty helpless with this question

+5
source share
1 answer

I wrote a Java applet for you. It will move the mouse cursor one pixel to the right and back every 59 seconds, effectively preventing the screen from shuttering.

, - createRobot , Robot. , .

import java.applet.Applet;
import java.awt.*;
import java.util.Timer;
import java.util.TimerTask;

/**
 * Moves the mouse cursor once in a minute to prevent the screen saver from
 * kicking in.
 */
public class ScreenSaverDisablerApplet extends Applet {

    private static final int PERIOD = 59;
    private Timer screenSaverDisabler;

    @Override
    public void start() {
        screenSaverDisabler = new Timer();
        screenSaverDisabler.scheduleAtFixedRate(new TimerTask() {
            Robot r = null;
            {
                try {
                    r = new Robot();
                } catch (AWTException headlessEnvironmentException) {
                    screenSaverDisabler.cancel();
                }
            }
            @Override
            public void run() {
                Point loc = MouseInfo.getPointerInfo().getLocation();
                r.mouseMove(loc.x + 1, loc.y);
                r.mouseMove(loc.x, loc.y);
            }
        }, 0, PERIOD*1000);
    }

    @Override
    public void stop() {
        screenSaverDisabler.cancel();
    }

}
+1

All Articles