One way would be to have your program prevent Sleep.
I’ve done it by using the API Keybd_Event() to send Keyboard Events that just press and release the Shift key. The GetLastInputInfo() API lets you check if the user has not done anything for X minutes and then press Shift.