Check out timer
in the autohotkey docs.
You could set a timer that checks every 5 seconds to run winexist
to test for the existence of c:\any.exe - and when it returns true
then your code could run c:\monitor.exe
Now that your code knows that c:\any.exe is running, your code could launch a second timer that checks for when its process is closed (check out process
in the ahk docs). When it is closed, then use winkill
to close the c:\monitor.exe process.
So, look up these commands:
winexist
timer
process