我的思路是: 在应用程序中创建一个txt文本; 通过”按键“记录键盘按键的值;
   
   句柄是一个什么概念?

解决方案 »

  1.   

    private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
    {
        MessageBox.Show(((int)(e.KeyChar)).ToString());
    }
      

  2.   

    不知道你要实现什么样的功能。
    搜一下钩子。看是不是符合。
    句柄。
    hwnd之类。
      

  3.   

    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在内存中维护的一个对象(窗口等)内存物理地址列表的整数索引
      

  4.   

    不清楚,不过结果,如果你按下的是 A键,就会显示A,如果你按下F1键,应该会显示VK_F1
      

  5.   

    e.keychar==num   键值查ASCII表吧
      

  6.   

    如果是全局的,而不是仅指当前窗体或程式,那就要使用钩子程式了。上次从网上下载了一个关于键盘与鼠标的钩子程式。如果楼主需要,给个Email,发给你了。