System.Windows.Forms.SendKeys.Send("{CAPSLOCK}");
            在VS2008中,这句代码为什么不起作用呢?其指示灯就是不亮

解决方案 »

  1.   

    使用下面的吧[DllImport("user32.dll")]
    static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,UIntPtr dwExtraInfo);  private void button1_Click(object sender, EventArgs e)
    {
        this.textBox1.Focus();    const int KEYEVENTF_EXTENDEDKEY = 0x1;
        const int KEYEVENTF_KEYUP = 0x2;
        keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);
        keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,(UIntPtr)0);}   
      

  2.   


    代码是没错,可为什么CAPSLOCK指示灯就是不亮(或变暗)呢?
    尽管下面的代码达到了效果:
                    this.textBox1.Focus();
                    System.Windows.Forms.SendKeys.Send("abc");  //Output:abc 
                    System.Windows.Forms.SendKeys.Send("{CAPSLOCK}");
                    System.Windows.Forms.SendKeys.Send("abc");  //Output:ABC
      

  3.   

    获取对象,再模拟键盘按键 
     this.textBox1.Focus();
     System.Windows.Forms.SendKeys.Send("{CAPSLOCK}");
      

  4.   

      this.textBox1.Focus();
      System.Windows.Forms.SendKeys.Send("{CAPSLOCK}"); 代码没错 ;
    可是指示灯就是不变亮或暗,诸位能帮我看 下你们那也是同样的么?