I'm writing a bot that should run on an executable in the background.
SendMessage(hWnd, WM_KEYDOWN, ((IntPtr)k), (IntPtr)0);
The line above will send a key to the process. If my cursor is in the game's chat box, it will type in the input into the chatbox.
If I am not in the chatbox and send that, it will do nothing until I tab into the process in which it acts as if I am holding that key down (I will walk in the direction of the key I am holding) until I press the key I sent in ('s' is the test key I am using) where it will stop. I also tried sending a message right after using the flag WM_KEYUP, but that didn't stop anything.
SetForegroundWindow (hWnd);
SendMessage(hWnd, WM_KEYDOWN, ((IntPtr)k), (IntPtr)0);
This segment will target the process and start moving.
I've been all over the internet trying to figure out how to make this work while in the background, as well as only send 1 input. I've messed around with spy++ but I figured that if it works when I send the command when I am tabbed in, it must be something else.
Here is the full class that I am operating with http://pastebin.com/Jbx9BfSm