哪位知道CapsLock键的键值嘛?也就是说我做了个CapsLock键按钮,我需要按下这个按钮后,键盘上CapsLock灯亮起来

解决方案 »

  1.   

    CapsLock     20
      

  2.   

    procedure TForm1.Button3Click(Sender: TObject);
    begin
      keybd_event( VK_NUMLOCK,$45,KEYEVENTF_EXTENDEDKEY or 0, 0 );
      keybd_event( VK_NUMLOCK,$45,KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP,0);
    end;
      

  3.   

    CapsLock:procedure TForm1.Button2Click(Sender: TObject);
    begin
      keybd_event( VK_CAPITAL,20,KEYEVENTF_EXTENDEDKEY or 0, 0 );
      keybd_event( VK_CAPITAL,20,KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP,0);
    end;
      

  4.   

    VOID keybd_event(    BYTE bVk, // virtual-key code
        BYTE bScan, // hardware scan code
        DWORD dwFlags, // flags specifying various function options
        DWORD dwExtraInfo  // additional data associated with keystroke
       );
    bVk      虚拟键值
    bScan    硬件扫描码
    dwFlags
       A set of flag bits that specify various aspects of function operation. An application can use any combination of the following predefined constant values to set the flags: Value Meaning   KEYEVENTF_EXTENDEDKEY If specified, the scan code was preceded by a prefix byte having the value 0xE0 (224).
        KEYEVENTF_KEYUP If specified, the key is being released. If not specified, the key is being depressed.dwExtraInfoSpecifies an additional 32-bit value associated with the key stroke.