I am developing a video media player using Java (using NetBeans). I am having a problem to keep my screen on, while the video is playing. Each time I play a video using my video player, the computer screen goes black after 15 min, while I am watching the video. How to keep it awake?
Asked
Active
Viewed 138 times
1 Answers
1
Schedueling your mouse to move programatically can do the trick.
TimerTask task = new TimerTask() {
@Override
public void run() {
try {
java.awt.Robot robot = new java.awt.Robot();
robot.mouseMove(0, 0);
robot.mouseMove(1, 1);
} catch (AWTException e) {
e.printStackTrace();
}
}
};
Timer timer = new Timer();
timer.scheduleAtFixedRate(task, 0, 900000); //move every 15 mins
yamenk
- 40,626
- 10
- 80
- 81
-
Thanks let me try it: was using this code to move the mouse but did not know where exactly include it – e.erick Aug 26 '17 at 15:42
-
Robot hal = new Robot(); while(true){ hal.delay(1000 * 30); Point pObj = MouseInfo.getPointerInfo().getLocation(); System.out.println(pObj.toString() + "x>>" + pObj.x + " y>>" + pObj.y); hal.mouseMove(pObj.x + 1, pObj.y + 1); hal.mouseMove(pObj.x - 1, pObj.y - 1); pObj = MouseInfo.getPointerInfo().getLocation(); System.out.println(pObj.toString() + "x>>" + pObj.x + " y>>" + pObj.y); } – e.erick Aug 26 '17 at 15:42
-