Hi there,
I've spent days trying to work this out. I just can't get it. I need to send keystrokes to an inactive game window (CoD:WWII) from a C# application. I've come across SendMessage which is imported from User32.dll. It almost works. It gets a handle on the game, and sends the string to the game, except it changes the title of the window instead of sending the message to the actual game itself.
Due to the ban on network connectivity within cheats here, I'm using the in-game chat to allow non-host players to send commands to the host to enable cheats. That bit works, but I want the cheat to type a message back in the chat to confirm that it has been activated. I can do it by forcing the game to have focus when sending messages, but that's pretty poor UX. I can't see how it can be so hard.
This is the function I have:
Code:
[DllImport("User32.dll")]
public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
public static IntPtr hWnd = FindWindow(null, "Call of Duty®: WWII Multiplayer");
public static void SendToCod(string msg) {
SendMessage(/*child*/hWnd, 0x000C, 0, msg);
}
Which I modified from here: https://stackoverflow.com/questions/...pad-in-c-win32
Any help will be greatly appreciated, Thanks