c# - How to send a proper message to Console application using user32.dll's SendMessage -


i'm trying send text console when requires console.readline() input, different thread (windows form textbox). problem can't seem figure out how send text , have show wrote it.

example: "test test 123" show in console as: test test &é" image: http://puu.sh/gijw8/e9f4d94bd5.png

using system; using system.windows.forms; using system.io; using system.runtime.interopservices; using system.diagnostics;  namespace consoleapplication1 {     public partial class form1 : form     {         [dllimport("user32.dll", entrypoint = "postmessagea")]         private static extern bool postmessage(intptr hwnd, uint msg, intptr wparam, int lparam);          [dllimport("user32.dll")]         static extern short vkkeyscan(char ch);          [dllimport("user32.dll", entrypoint = "sendmessagea")]         public static extern int sendmessage(intptr hwnd, int umsg, int wparam, string lparam);          [dllimport("kernel32.dll")]         internal static extern intptr getconsolewindow();          public static intptr hwnd = getconsolewindow();          public form1()         {             initializecomponent();         }          private void textbox1_keydown(object sender, keyeventargs e)         {             if (e.keydata == keys.enter)             {                 e.suppresskeypress = true;                 textbox tb = (sender textbox);                  /*for (int = 0; < tb.text.length; i++)                 {                 postmessage(hwnd, 0x100, (intptr)vkkeyscan(tb.text[i]), 0); -> crap doesn't support uppercase , numbers <.<                 }*/                  postmessage(hwnd, 0x100, (intptr)keys.enter, 0);                 tb.clear();             }             sendmessage(hwnd, 0x000c, 0, "herpityderp"); // -> crap changes console title -_-         }     } } 

i tried using sendmessage, changes console's title :/

i'd thankful if guys come solution

a console app doesnt have windows message pump, might want see how can hook console's stdout...


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -