请问如何确定键盘上的Caps Lock灯的状态? ( 积分: 50 )

  • 主题发起人 主题发起人 chengang_1981
  • 开始时间 开始时间
C

chengang_1981

Unregistered / Unconfirmed
GUEST, unregistred user!
我就是想知道Caps Lock灯的状态,是亮的还是暗的,请问各位大虾这应该如何实现?<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 谢谢!
 
我就是想知道Caps Lock灯的状态,是亮的还是暗的,请问各位大虾这应该如何实现?<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 谢谢!
 
function GetKeyLock(vcode: Integer):boolean; &nbsp;//获取或设置键盘状态<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//VK_INSERT VK_CAPITAL VK_NUMLOCK VK_SCROLL<br>begin<br>result:=Odd(GetKeyState(vcode));<br>end;<br><br>Caps Lock使用VK_CAPITAL <br>灯亮返回true
 
procedure TForm1.Button1Click(Sender: TObject);<br>var<br> &nbsp;KeyNum: TKeyboardState;<br>begin<br> &nbsp;if not GetKeyboardState(KeyNum) then exit;<br> &nbsp; if KeyNum[VK_CAPITAL] = 1 then<br> &nbsp; &nbsp; Showmessage('CAPITAL &nbsp;ON')<br> &nbsp; else<br> &nbsp; &nbsp; ShowMessage('CAPITAL &nbsp;OFf');<br>end;
 
procedure TForm1.Button1Click(Sender: TObject);<br>var<br> &nbsp;KeyBoardState :TKeyboardState;<br> &nbsp;isGrey :Byte;<br>begin<br> &nbsp;GetKeyboardState(keyBoardState);<br> &nbsp;isGrey :=KeyBoardState[VK_CAPITAL];<br> &nbsp;if isGrey&lt;&gt;0 then ShowMessage('Caps Lock灯亮')<br> &nbsp;else ShowMessage('Caps Lock灯未亮');<br>end;
 
多人接受答案了。
 
后退
顶部