Results 1 to 2 of 2
  1. #1
    Sala296's Avatar
    Join Date
    Aug 2017
    Gender
    male
    Location
    A far away land
    Posts
    56
    Reputation
    10
    Thanks
    173
    My Mood
    Busy

    Use the SendMessage method from "User32.dll" to send inputs to unfocused game window

    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

  2. #2
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    You're using WM_SETTEXT on the game window, which will change it's title. You'd need to get a handle to the text input control in the game, which I don't think is a win32 control, so this method will fail regardless.
    Ah we-a blaze the fyah, make it bun dem!

Similar Threads

  1. [WTB] Custom Spotify that doesn't use the Family method?
    By gA$TY4gwsrgwrgwrgr in forum Buying Accounts/Keys/Items
    Replies: 1
    Last Post: 03-06-2017, 12:01 PM
  2. [Request] Would this be possible using the same method as gun adding?
    By Crank'D in forum Alliance of Valiant Arms (AVA) Discussions
    Replies: 3
    Last Post: 01-28-2013, 08:10 PM
  3. SANA - can I still put in skins by using the gvi method?
    By Xstozin in forum Sudden Attack General
    Replies: 1
    Last Post: 12-16-2011, 09:41 AM
  4. Displaying the IAT list from within a injected dll
    By Anddos in forum C++/C Programming
    Replies: 2
    Last Post: 08-18-2010, 04:09 AM
  5. Replies: 8
    Last Post: 01-03-2009, 09:11 AM

Tags for this Thread