日期:2014-05-17 浏览次数:21220 次
private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { MessageBox.Show(((int)(e.KeyChar)).ToString()); }
------解决方案--------------------
IntPtr hwnd = FindWindow(null, "a.txt");
if (hwnd.ToInt32() != 0)
{
if (SetForegroundWindow(hwnd))
SendKeys.SendWait(Keys.A.ToString());
}
else { MessageBox.Show("记事本没有运行 "); }
Process myProcess = System.Diagnostics.Process.Start(@"D:\WINDOWS\notepad.exe");
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
myProcess.WaitForInputIdle(1000);
if (myProcess.Responding)
{
SendKeys.SendWait("文字!");
SendKeys.SendWait("{ENTER}");
SendKeys.SendWait("%EA");
SendKeys.SendWait("^C");
SendKeys.SendWait("^V");
SendKeys.SendWait("%FS");
SendKeys.SendWait(@"C:\Test.txt");
SendKeys.SendWait("%S");
}
private void Form1_KeyUp ( object sender , KeyEventArgs e )
{
MessageBox.Show(e.KeyCode.ToString ( )) ;
}
句柄是一个32位的整数,是Windows在内存中维护的一个对象(窗口等)内存物理地址列表的整数索引