private const byte VK_A = 0x41;
private const byte KEYEVENTF_SILENT = 0x0004;
[System.Runtime.InteropServices.DllImport("Coredll.dll")]
private static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,
uint dwExtraInfo);
private void button1_Click(object sender, System.EventArgs e)
{
this.textBox1.Focus();
keybd_event(VK_A, 0, KEYEVENTF_SILENT, 0);
}
Note: Just like it says at the top of the file that I mentioned to you
before:
"The methods in this class will only work if the textbox, on which the
requested operations are to be performed, has the focus when the operation
call is made. Typically this means calling these methods from a menu
(MainMenu or ContextMenu). If the call must be made from inside an event
handler for another control, then set focus back to the textbox from inside
the event handler before making the operation call."
Virtual Key Codes:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/w98ddk/hh/w98ddk/keycnt_4fqw.asp