2

I'm wanting to create a simple program in C# which sends the SPACE key to an inactive window or process (Wow.exe). However, I have no knowledge of C# what so ever so if you want to try help me please do but if you can't be bothered explaining to a noob that's fine ;)

So basically the little program will be for the game World of Warcraft and will hopefully send a SPACE key to the game every 30 seconds and make the character jump. Preventing the character to automatically going away from keyboard.

It will be a single buttoned program which will start sending the SPACE key once you click the button and will stop when the program is closed. But, I want it to send the key to the game even if it isn't the current active window. So I can be watching a film on Netflix and have it doing it in the background.

What would I put inside this when the button is clicked?...

private void btnStart_Click(object sender, EventArgs e)
{

}

If it's going more complicated than inserting some code inside there just say and I won't bother trying to make it :P

2 Answers2

4

You would need to grab the Window Handle (Process.MainWindowHandle), and then P/Invoke the SendMessage function with WM_KEYDOWN and the virtual key code for space bar.

Sam Axe
  • 33,313
  • 9
  • 55
  • 89
  • I'll have a read later and try getting it working. Thanks for the help. =) –  Apr 04 '12 at 17:39
0

It is unable to send to inactive Window as for active just write Keys.Send("{SPACE}");or Keys.SendWait("{SPACE}");

Mr.V.
  • 128
  • 1
  • 1
  • 7