I created a digital full screen Clock in Processing. I also created a executable file to run it directly via double click. My OS is MacOS High Sierra. When I run it, my laptop goes to sleep after some time. I want to disable sleeping while my clock is running. Is there a programming way to do this.
1 Like
Thanks for replying but I want it to be done automatically. Like whenever program starts it disable sleep and when program ends normal status is enabled. Similar to like when we play video or watch movie we don’t have to disable sleep option. Something like that.
i read about a JAVA trick
so i put that into code but untested…
import java.awt.*;
while (true) {
try {
Thread.sleep(1000); //1000 milliseconds is one second.
}
catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
Point mouseLoc = MouseInfo.getPointerInfo().getLocation();
try {
Robot bot = new Robot();
bot.mouseMove(mouseLoc.x, mouseLoc.y);
//println("you see me?");
}
catch (AWTException e) {
e.printStackTrace();
}
}
but need to implement after testing ? like
import java.awt.*;
void setup() {
size(200,200);
}
void draw() {
background(200,200,0);
rect(mouseX,mouseY,20,20);
call_disable_sleep();
}
void call_disable_sleep() {
if ( frameCount%100 == 0 ) {
Point mouseLoc = MouseInfo.getPointerInfo().getLocation();
try {
Robot bot = new Robot();
bot.mouseMove(mouseLoc.x, mouseLoc.y);
println("you see me?");
}
catch (AWTException e) {
e.printStackTrace();
}
}
}