Loading...
Logo
Processing Forum
I have this sketch that has to run for a couple of days during an art meet and I can't be present at all times.

Since it could crash while I'm not there, i was wondering if there was any known way to make Windows restart my sketch if it fails.

An automatic boot on startup is easy, but anyone has an idea how to restart after a crash?

Replies(3)

A possible way to do this is to have a AutoHotkey (or AutoIt) script watching regularly if the sketch window is active. If not, it can run the sketch again. Would need a bit of learning (these are actually languages) but it is well worth the time (and not so hard, and the AHK forum (at least) is friendly and helpful.
Thanks for the great response! 

With some test I came up with this solution in auto hotkey, if anybody needs something similar


Copy code
  1. SetTitleMatchMode 2

    Loop{
    IfWinNotExist Motion101acceleration
    Send #d
    Run E:\hotkeytest\Motion101accelerationCar.bat, E:\hotkeytest\
    Sleep 10000
    }


The Send line doesn't do what it should do but removing it breaks the script (it has something to do being the first line after IfWinNotExist).
Mmm, the Run is outside of the test, so it might be run systematically, no?
Something like:
Copy code
  1. SetTitleMatchMode 2
  2.  
  3. Loop
  4. {
  5.   IfWinNotExist Motion101acceleration
  6.   {
  7.     Run E:\hotkeytest\Motion101accelerationCar.bat, E:\hotkeytest\
  8.     Sleep 10000 // Wait a bit more for the sketch to start
  9.   }
  10.   IfWinNotActive Motion101acceleration
  11.   {
  12.     WinActivate // Ensure the window is always topmost
  13.   }
  14.   Sleep 10000
  15. }