How can I make my code control the keyboard to play another game?

38 views Asked by At

There's a puzzle game called Zen Puzzle Garden, and I just wrote a program that solves the puzzles in the game. Right now, it does a brute force search for a solution, then spits out the necessary moves to solve the puzzle: up, down, left, and right.

But what I want is to run the game on my computer, and feed those moves from my program into the game, so I watch the game being solved automatically.

What is the easiest way to do this?

I should mention probably that my code is written in C.

1

There are 1 answers

0
Brian Watson On
System.Windows.Forms.SendKeys.SendWait("String you want");

Or

System.Windows.Forms.SendKeys.SendWait(Keys.Up.ToString());

Note that if you enter a string it will send the whole string. So you should probably make a switch/case to see what Key you want to compute.