There are a variety of strategies you can use to build a bot. If you can't just loop keypresses, then you need some kind of data from the program in the form of a pixel color (lousy solution, can't minimize the game), or in the form of data from memory (harder to accomplish, more maintenance).
It really depends what you're targeting and what your level of experience is.