I am working on a web application that needs to be active on the monitor sometimes for hours without anyone touch the computer.
The problem is that some computers have their screen saver, or worse - sleep mode while their inactive.
I'm trying to think of a way to bypass it. I searched for java applets or maybe a flash file that does only that. I found nothing, unfortunately.
I'm sorry for the too general question but I'm pretty helpless with this subject
I've written the Java applet for you. It will move the mouse cursor one pixel to the right and back every 59 seconds, effectively preventing the screen saver from kicking in.
Note that because of security restrictions this applet will need to be signed and granted the createRobot
permission to work on the client, otherwise it will fail to initialize the Robot
class. But that's a problem outside this question's scope.
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();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With