;
; Turn script into wrapper for a program
;

CheckWinExist(Window) {
    if !WinExist(Window) {
        ExitApp
    }
}

Run %WrapperPath%
WinWait %WrapperWindow%

; Check if window exists once per second
WrapperFunc := Func("CheckWinExist").bind(WrapperWindow)
SetTimer, %WrapperFunc%, 1000