I've got a program I like to run automatically during certain hours (for example between 08:00 and 19:00) and close the program after that time.
And also start it again when it's 08:00. And if the program shuts down between 08:00 for whatever reason it will start it again after for example after 60 sec.
It's for a gallery space so they can just keep the computer on and it runs automatically.
I think I got a base for starting and keeping watch for the program but some help for the rest would be nice :
Code: Select all
TIMER = 5000
title= program
File=
WinWaitActive, ahk_class GHOST_WindowClass
WinGetTitle, WinTitle, program.exe
file := RegExReplace(title, ".*\[(.*)\]$", "$1")
if file=
{
msgbox, CANNOT GET FILENAME FROM TITLE: "%title%"
exitapp
}
TrayTip, EXE, % "Now watching for " file
Loop
{
IfWinNotExist, %title% ahk_class GHOST_WindowClass
{
IfWinExist, ahk_exe blender.exe
goto next
TrayTip, EXE, % "Restarting " file
Run, location file here %file%
WinWaitActive, ahk_class GHOST_WindowClass
Sleep, 6000
Send, ^{f12}
}
next:
Sleep TIMER
}
+0::exitapp