5

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

4

1 に答える 1

1

Java アプレットを作成しました。マウス カーソルを 59 秒ごとに 1 ピクセル右に移動し、スクリーン セーバーが起動するのを効果的に防ぎます。

セキュリティ上の制限により、このアプレットは署名され、クライアントで動作する権限付与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();
    }

}
于 2013-01-18T10:05:51.263 に答える