Reputation: 339
Does anyone have any idea how i could modify the example from http://www.codeproject.com/Articles/14519/Using-Windows-APIs-from-C-again
in order to send strings of data to a textbox?Using Spy++ i was able to determine the app caption, and the buttons, and edits captions of the targeted app, And i have succesfully pressed a button, but i would also like to be able to put some text in a textbox.Any help would be appreciated
Upvotes: 1
Views: 6932
Reputation: 5380
Assuming you have the HWND of the TextBox to which you want to send the text, this code should do it:
public partial class Form1 : Form
{
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hwnd, int msg, IntPtr wParam, [MarshalAs(UnmanagedType.LPStr)] string lParam);
private const int WM_SETTEXT = 0x000C;
...
public void SetTextOnRemoteTextBox(string text)
{
SendMessage(textBox1.Handle, WM_SETTEXT, (IntPtr)text.Length, text);
}
Cheers
Upvotes: 3