純粹的讀值
要應用要再另外處理
直接分享
網路上搜尋的 自己在稍微改了一下
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) As Long
Function GetCapslock() As Boolean
GetCapslock = CBool(GetKeyState(vbKeyCapital) And 1)
End Function
Function GetNumlock() As Boolean
GetNumlock = CBool(GetKeyState(vbKeyNumlock) And 1)
End Function
Function GetScrollLock() As Boolean
GetScrollLock = CBool(GetKeyState(vbKeyScrollLock) And 1)
End Function
Dim aa$, bb$
Private Sub Command1_Click()
aa = "Num狀態:"
bb = IIf(GetNumlock, "狀態ON", "狀態OFF")
aa = aa & bb & vbCrLf
aa = aa & "Caps狀態:"
bb = IIf(GetCapslock, "狀態ON", "狀態OFF")
aa = aa & bb & vbCrLf
aa = aa & "Scroll狀態:"
bb = IIf(GetScrollLock, "狀態ON", "狀態OFF")
aa = aa & bb & vbCrLf
MsgBox aa
End Sub
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。