42 thoughts on “Video Tutorial – Send Keys To An Inactive Window – Windows Messages

  1. So this is kind of like keybd_event and sendinput api functions except this works on inactive windows. I wonder if this would work for halo. Again good tutorial.

    btw I’ve been wondering if its possible to reenable dev for halo, not ce. I used findpattern to find an address which I think is for devmode, though when I try it, it freezes the game until i change it back. Maybe some security, if so is there a way around this? I know that addresses like deathless, infinite ammo, bottemless still exist in it, so maybe dev all together does too.

  2. Hi,

    I’ve try to use this “wonderfull” tutorial with AERIA GAME Shaiya, but does not work. Using Spy++ all “Properties” windows data are “grey” and Keyboard can go into chat but not into the game.

    Can you help me to understand why and how to solve it?

    thanks much

    Tesitos

    1. I don’t know what it means if the Windows Data are gray but your game is probably a DirectX game which uses DirectInput for keyboard detection so this method probably won’t work. You have to dig (read reverse) deeper.

      1. hey, this is a great tut, but i was wondering if you could make a tut for code injection. like lets say i wanted to make a program that injects a .dll into halo. or just modify halo’s memory with hotkeys for unlimited ammo and such. I know how to use trainer makers but i want to learn how to do things myself. Your tut’s are really helpful.

        1. I won’t make a tutorial on how to inject a DLL but I can certainly write a tutorial on how to write a DLL Trainer.

  3. Hey cool tut, I got it working for this older game I play. I was just wondering if I can make it so when I push the send button it sends the message and also pushes enter so it posts it in-game. I leave my console open and minimize the game and send it, it goes into the console but i have to re-open the game and push enter to send. Thanks.

    1. I used this for Minecraft and I can easily send “Enter”. If the game requires for some reason focus then you can just make it go into focus by using the SetForegroundWindow() / SetActiveWindow() (can’t remember which one) API before sending Enter.

      1. Hey thanks for the response, I hate to bother you with it but can you please show me how you got enter to work? My Spy++ in-game shows enter with the wParam “0000000D” so that’s what Ive been trying but its not sending anything. I’m a real amateur programmer so I hate asking because it’s something dumb on my part, but I’m lost here.

          1. Thanks man works like a charm, I went with
            ” if (VM.windowExists())
            { VM.sendText(txtBoxSend.Text);

            VM.sendKey(Keys.Enter);
            }
            else if (VM.windowExists())
            VM.sendKey(Keys.Enter);
            else
            messagebox”

            It sends it flawlessly. :). This is cool as hell, thanks for your help.

            1. Edit: minus the first “VM.sendKey(Keys.Enter);” after it sends the textbox, thats not really there, thats how i first tried it and its why i added an else if.

  4. Hey awesome tutorial man.. i learned alot.
    But now i was wondering .. how do you write a program that catches all keyboard input while inactive.. kinda like a keylogger but im not making that i want to make a media player that reacts on differen keys while inactive

    1. I can write a tutorial on that as well. You have to use GetAsyncKeyState and check in a loop if your hotkeys are being pressed. Alternatively you can install a keyboard hook.

      1. Yeah, I’d like to see a tutorial for this as well. I have an AI bot that needs to receive the human player’s input while inactive and the game is active.

  5. I like the tutorial. Can you provide some direction for the following? I want to send CTRL-SHIFT-R to a window every 60 seconds. Do you have an example of the “send key” code that repeats every n seconds?

    Thanks,
    R. C.

      1. Hi,

        Thanks for posting this tutorial, very helpful. I have one question:

        You code works perfectly when target window is Notepad however when target window is a Google Doc running in IE 7 no text gets sent – any thoughts?

        Thanks.

  6. Hi,
    Thanks for posting this tutorial, very helpful. I have one question:
    You code works perfectly when target window is Notepad however when target window is a Google Doc running in IE 7 no text gets sent – any thoughts?
    Thanks.

    1. Have you tried Spy++ and hover over Google Doc? It might not be running inside IE instead running in Flash or Java.

  7. Thanks a lot! This is exactly what I need to create two applications and keep the focus in one application while the other application receives keyboard events!

  8. I can get this to more for some programs but I can’t get it to work for games like halo or nexus. How could you send chars to these games?

        1. I can’t test the above method because GetProcessIdOfThread only works on vista and higher. I’ll check the guiltySpark source to see how that works.

  9. Hi , I like this very much works perfect exept one thing. Some of my characters are sended wrong like
    / is 7 or T is t some other weird characters also how can I fix this .

    Thank you .

    1. I had the same problem at first…cannot remember how I solved it. In the additional parameters you can define the SHIFT state I believe.

        1. public void sendChar(char pChar)
          {
          Win32.PostMessage(eClassHandle, Win32.WM_KEYDOWN, Win32.VkKeyScan(pChar), 0x00140001);
          Win32.PostMessage(eClassHandle, Win32.WM_CHAR, 0x00000000 + (Int32)pChar, 0x00140001);
          Win32.PostMessage(eClassHandle, Win32.WM_KEYUP, Win32.VkKeyScan(pChar), 0xC0140001);
          }

          This is what I use, maybe it works for you?

  10. I found it for those who have the same problem here the solution :

    // Win32.PostMessage(eClassHandle, Win32.WM_KEYDOWN, Win32.VkKeyScan(pChar), 0x00140001);
    Win32.PostMessage(eClassHandle, Win32.WM_CHAR, 0x00000000 + (Int32)pChar, 0x00140001);
    Win32.PostMessage(eClassHandle, Win32.WM_KEYUP, Win32.VkKeyScan(pChar), 0xC0140001);

  11. Hi Patrick,

    How do you simulate arrow keys? I have tried two methods different PostMessage,

    public static extern bool PostMessage(int hWnd, uint Msg, uint wParam, uint lParam);
    public static extern bool PostMessage(int hWnd, uint Msg, Keys akey, uint lParam);

    where both works for a to z and other keys, but only the navigation keys do not work.

    When I run the line below,
    Win32.PostMessage(windowHandle, Win32.WM_KEYDOWN, Keys.Up, 0x01480001);
    I get wParam:00000037 from my raw input, but when I press Up arrow on my keyboard, Spy++ registers wParam:00000026. Do you have any idea why this is happening? Or the most important question, do you have any idea how to send a keystroke representing Up arrow?

  12. Hey could you help me a little with sendkeys tutorial?
    I want to make it in vb.net
    Tried,no errors but it wont work,i dont know what is the problem.
    maybe this conversion “Win32.VkKeyScan(CChar(CStr(pKey)))”

    This message is for Patrickssj6 , that guy who made the sendkeys tutorial.
    I really need help
    please contact me via email “matrix_boy84@yahoo.com” or via skype MALWARE442

  13. I still dont understand why do you have SendKeys and SendCharacter they do the same? Also the tutorials seems very complicated I dont understand everything. Can you upload a more detailed tutorial on YouTube that would be way better. Does this work the same when I use it for a game btw?

Leave a message

Your email address will not be published. Required fields are marked *

*