so i had a question about how i solved this, so here's more detail:
>note: this solution is for a mac<
step 01: write some script into your processing .app to shut down at certain intervals
step 02: use cron to start up your standalone app
step 01:
insert this into draw() somewhere... i have it at the end of the loop
- int h = hour();
- int m = minute();
- int s = second();
- if ( (h == 3) && (m == 59) && (s == 58) ) { //4am
- robby.keyPress(KeyEvent.VK_ESCAPE);
- }
- else if ( (h == 7) && (m == 59) && (s == 58) ) { //8am
- robby.keyPress(KeyEvent.VK_ESCAPE);
- }
- //etc...
i found i had errors quitting the standalone .app unless i used a robot to push the "esc" key. you can learn more about
using a robot from the processing wiki (which is where i got this portion of the code)... basically before setup you need
- import java.awt.Robot;
- import java.awt.AWTException;
- import java.awt.event.InputEvent;
- Robot robby;
and in setup() you need
- try
- {
- robby = new Robot();
- }
- catch (AWTException e)
- {
- println("Robot class not supported by your system!");
- exit();
- }
i also added the kinect.quit() command to the escape key press because i found sometimes the kinect would crash even if kinect.quit() was in void stop()
- void keyPressed() {
- switch(key) {
- case 27: //keycode 27 = esc
- kinect.quit();
- super.stop();
- break;
- }
- }
step 02: use cron to start up the program again
i used
CronniX and two lines to start up the app at 4 and 8am should read something like
0 4 * * * open /Users/Username/Desktop/yourP5app.app
0 8 * * * open /Users/Username/Desktop/yourP5app.app
note, hours are 0-23, also remember to hit save in CronniX