I'm having difficulty working with SendMessage()
, some programs work from one method and others from another ...
To write to Notepad, do the following:
[DllImport("user32.dll")]
public static extern IntPtr PostMessage(IntPtr Handle, uint Message, int lparam, int wParam);
[DllImport("user32.dll", EntryPoint = "FindWindowEx") ]
public static extern IntPtr FindWindowEx(IntPtr Handle, IntPtr Child, string lparam, string wParam);
static Process p = Process.GetProcessesByName("Notepad")[0];
public static void Message()
{
string msg = "Teste";
IntPtr child = DLLs.FindWindowEx(p.MainWindowHandle, new IntPtr(0), "Edit", null);
foreach(char c in msg){
DLLs.PostMessage(child, 0x102, Convert.ToChar(c), 0);
}
}
But your I need to send a message to a game, a spreadsheet in Word, Notepad ++, DreamWeaver, etc., does not work ...
How does it work in other cases? I read a bit about Spy ++, but would it be just the same?