First you should fix your keyboard. I think the caps-lock key is stuck. 😉
What you want to do is easy, but first you need to define better what you want. Who calculates the period of time? What should happen if a high pulse is detected and the program is already running? Should it ignore the pulse or extend the current run time? etc.....
Also, typically the program should always run, but perform a certain task for a certain period of time triggered by an event. A non-running program cannot etect a high pulse, for example.