How do you keep the machine awake?

On Windows, use the SystemParametersInfo function. It's a Swiss army-style function that lets you get/set all sorts of system settings.

To disable the screen shutting off, for instance:

SystemParametersInfo( SPI_SETPOWEROFFACTIVE, 0, NULL, 0 );

Just be sure to set it back when you're done...


I use this code to keep my workstation from locking. It's currently only set to move the mouse once every minute, you could easily adjust it though.

It's a hack, not an elegant solution.

import java.awt.*;
import java.util.*;
public class Hal{

    public static void main(String[] args) throws Exception{
        Robot hal = new Robot();
        Random random = new Random();
        while(true){
            hal.delay(1000 * 60);
            int x = random.nextInt() % 640;
            int y = random.nextInt() % 480;
            hal.mouseMove(x,y);
        }
    }
}