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 177 times
1
-
2Related (Java): [How do you keep the machine awake?](https://stackoverflow.com/questions/52874/how-do-you-keep-the-machine-awake) – showdev Aug 25 '17 at 17:12
-
1Does this answer your question? [How do you keep the machine awake?](https://stackoverflow.com/questions/52874/how-do-you-keep-the-machine-awake) – BalusC Mar 23 '23 at 16:34
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
- 46,736
- 10
- 93
- 87
-
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
-