You can use nearly any language with read and write functions even node.js is possible.
There are several ways to do it.
1. Hook a game function wich gets called often enough, and execute your code there.
2. Create a codecave with your own timer, and execute your code.
3. Create a external programm with timer and read the health and then simulate a key press.
Since you aren't in a specific language sub forum you will not likely get any pasta code