[Help]C# Postmessage send string

04/22/2012 10:46 Cyberghost77#1
hey mates,
need some help i know how to send keys:
Code:
PostMessage(p.MainWindowHandle, WM_KEYDOWN, (int)Keys.A,1);
Code:
PostMessage(p.MainWindowHandle, WM_KEYUP, (int)Keys.A,1);
but i want to send a string to the window i tryed :
Code:
foreach (char item in text)
        {
        PostMessage(p.MainWindowHandle,WM_KEYDOWN,Convert.Int32(item), 1);
        PostMessage(p.MainWindowHandle, WM_KEYUP, Convert.Int32(item), 1);  

            System.Threading.Thread.Sleep(10);
        }
but i wont work
if i send "test" i get "tt55" in my window :S
pls help
04/27/2012 13:17 SwarN#2
If you want to send text to notepad try this:


Code:
//WM_PASTE = 0x302
//Copy the String/Text what you want to Clipboard,
//PostMessage Send you Clipboard via Paste to the Handle what you choose
Clipboard.SetText(text);
PostMessage(p.MainWindowHandle, WM_PASTE, 0, 0);

Do not forget the "thanks" button if this is what you wan't
04/27/2012 13:45 Kraizy​#3
why would u need to copy the text to ur clipboard before..? kinda senseless
04/28/2012 11:21 SwarN#4
Because PostMessage only let you push 1 button,
so with this method you only have to call the method 1 time's.

If you have a better solution you can post it here, but dont spam in this thread! he want help and no spam!
04/28/2012 11:26 Kraizy​#5
There are many ways on how to use Post-/SendMessage.
04/29/2012 11:28 Xijezu#6
Code:
        [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
        public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, IntPtr lParam);

        SendMessage(Handle, 0x000C, 0, Marshal.StringToHGlobalAuto("Message goes here"));
If I remember right, 0x000C was WM_SENDTEXT.
That's what I'm using. ;)
04/29/2012 11:56 Kraizy​#7
Well, its VB.NET but that should not be a big problem..
[Only registered and activated users can see links. Click Here To Register...]
And yes, 0xC is WM_SETTEXT
04/29/2012 15:42 Cyberghost77#8
Quote:
WM_PASTE = 0x302
thats not a good solution but the only one works with PostMessage

-----------
hm tryed it wont work dunno why :S

Quote:
public static void sendstring(string text, string prozess)
{
Process[] procs = Process.GetProcessesByName(prozess);
proccID = procs[0].Id;
Process p = Process.GetProcessById(proccID);
Clipboard.SetText(text);
PostMessage(p.MainWindowHandle, WM_PASTE, 0, 0);
}
04/29/2012 16:12 Kraizy​#9
Any error message?
04/30/2012 11:05 SwarN#10
on which process do you want to send text?
if it's a mmorpg there are much more problem's. Test it with notepad
05/01/2012 11:43 Cyberghost77#11
i want to send it to the login from League of Legends.
Sending keys with
Quote:
Sendkeys.send...
works great but i wanna login background
05/03/2012 09:28 SwarN#12
That is what i mean,

MMORPG's are very different from normal Applications like notepad or textpad etc...

with Send/PostMessage you will have no success, try another method, like funktion hooking or send login packets etc...

Or you make your LoL 1 Sek to the aktiv form an send all keystrokes within 1 second and reaktivate the form where you are before. Because it's only the login :/
05/03/2012 10:18 Cyberghost77#13
my problem is iam able to send keys like thw 2th method in my first post ...
u know any good methodes ? my u can help me :O

---------------- edit --------------------

think u are right but just because if the window is not active the textbox ist also not aktive
05/03/2012 11:18 SwarN#14
yes, you don't have a focus to the Nickname field or the Password field.

You can try to Set this via ProcessRead/Write Memory,
and then only send the "Return" for Login.

i don't play LoL so i can't help you exactly only can give you "tips"