怎么没人理我
请诸位帮帮忙吧

解决方案 »

  1.   

    调用API GetKeyStateDeclare this class first:  

     
    ComVisibleAttribute(false), 
     
    SuppressUnmanagedCodeSecurityAttribute() 
     

     
    internal class NativeMethods 
     

     
         [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true, CallingConvention=CallingConvention.Winapi)] 
     
         public static extern short GetKeyState(int keyCode); 
      
         public static int HIWORD(int n) 
     
         { 
     
              return ((n >> 16) & 0xffff/*=~0x0000*/); 
     
         } 
      
         public static int LOWORD(int n) 
     
         { 
     
              return (n & 0xffff/*=~0x0000*/); 
     
         } 
     

      
    Then when you want to check if Caps is down or ON, call:  
    short state = NativeMethods.GetKeyState(0x14 /*VK_CAPTIAL*/); 
      
    bool capsKeyDown = NativeMethods.HIWORD(state); 
     
    bool capsKeyON = NativeMethods.LOWORD(state);
      

  2.   

    楼上的,你可以
    我同意你的方法,请楼主试试