Im not quite sure why this wont work.Code:private void button1_Click(object sender, EventArgs e) { const int WM_KEYDOWN = 0x100; const int WM_KEYUP = 0x101; Form1 Frm = new Form1(); //IntPtr notepad = FindWindow("Form1", null); IntPtr editx = FindWindowEx(this.Handle, IntPtr.Zero, "textbox", null); PostMessage(editx, WM_KEYDOWN, (int)Keys.A, 0); PostMessage(editx, WM_KEYUP, (int)Keys.A, 0); }
Im trying to send the Key "A" to a textbox on the form that the button is pressed on.
Also, where the code is commented, What would I lock onto? Form1? Form 1's text?
Thanks in advance
Results 1 to 8 of 8
Thread: [C#][Help]Postmessage Api
- 03 Aug. 2010 12:14am #1
[C#][Help]Postmessage Api
Shh, I'm watching My little pony.
- 03 Aug. 2010 02:54am #2
What. Please specify more. Are you trying to access another control on a different form? If so you need to make that control a public static or have a functions you can call from the other form thats a public void or something that will put the text in the designated area.
Let's say this is frmSettings that you want to send the data to. You would have a public void like this that will put the text in the text box.
PHP Code:public void EditText(String Data)
{
txtWhatEver.Text = Data;
}
PHP Code:private void btnWhatEver_Click or w/e(what ever goes here)
{
frmSettings Settings = new frmSettings();
Settings.EditText(Data you want the text box to have);
}
- 03 Aug. 2010 03:31am #3
looks hard
- 03 Aug. 2010 03:42am #4
Ohh no its not that
Postmessage sends a command to a hwnd or specific control, in this case I want to send the command of A key down, and up, without taking over the keyboard.
I looked all through google and couldnt find anything for C#, over Vb.
Its kindalike a silent sendkeys.Shh, I'm watching My little pony.
- 03 Aug. 2010 03:45am #5
- 03 Aug. 2010 01:24pm #6
I dont want to use SendKeys. Because it takes over the keyboard, and the form must be focused.
Post message is the complete opposite of that.Shh, I'm watching My little pony.
- 03 Aug. 2010 09:17pm #7
C# Post Message Api
The first twrked for me.
- 03 Aug. 2010 10:40pm #8
Thanks.
Ill mess around with it abit.
Oh shi-
It works. I love you chad.Last edited by Bman; 03 Aug. 2010 at 10:42pm.
Shh, I'm watching My little pony.