Hi, I've been researching these past few days on SendMessage and FindWindow and I've been looking at example source codes but I just can't seem to understand the process between it.

At first I just wanted to send a simple message from a textbox to the open chat of another process which is some game. I'm running this game / my server with a cmd console and now I just want to send userinput from a textbox to the cmd since the server uses simple command lines for moderation. Any help will be greatly appreciated thank you.

I've tested a lot of things out and managed to get some macros working but that's about it:

[DllImport("user32.dll", CharSet = CharSet.Auto)]
        private static extern IntPtr FindWindow(string IpClassName, string IpWindowName);

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);

        [DllImport("user32.dll", EntryPoint = "SendMessage")]
        public static extern int SendMessage(int hWnd, int Msg, int wParam, int lParam);

        protected override bool  ProcessCmdKey(ref Message msg, Keys keyData)
        {
            const int WM_KeyDown = 0x100;
            const int WM_SYSKeyDown = 0x104;

            if ((msg.Msg == WM_KeyDown || (msg.Msg == WM_SYSKeyDown)))
            {
                switch(keyData)
                {
                    case Keys.Down:
                        MessageBox.Show("Down Arrow Captured");
                        break;
                    case Keys.Up:
                        MessageBox.Show("Up Arrow Captured");
                        break;
                    case Keys.Tab:
                        MessageBox.Show("Tab Key Captured");
                        break;
                    case Keys.Control | Keys.M:
                        MessageBox.Show("<CTRL> + M Captured");
                        break;
                    case Keys.Alt | Keys.Z:
                        MessageBox.Show("<ALT> + Z Captured");
                        break;
                    case Keys.R:
                        IntPtr handle = FindWindow(null, @"C:\windows\system32\cmd.exe");
                        
                        break;
                }
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }

Can anybody help me please. I essentially wanted to send text input to the process of my game, but since the current server I'm running is run by the cmd console I supposed I I'll output the text to the console

sorry bump, I'm still reading articles on different websites but I'm still confused on how to get aroudn this

This article has been dead for over six months. Start a new discussion instead.