Message 1 of 6
Capslock
Not applicable
04-12-2002
04:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Why doesn't this stinking code toggle the stupid capslock light on the
keyboard...it toggles the capslock mode, but not the stupid light!!! Thanks
for your help.
'* * * * * * * * * * *
'Sample call
Public Sub testKB()
Dim oKeyboard As CKeyboard
Set oKeyboard = New CKeyboard
oKeyboard.capsOn = False
Set oKeyboard = Nothing
End Sub
'* * * * * * * * * * *
'CKeyboard Class Module
Option Explicit
Private Const VK_CAPITAL = &H14
Private Const VK_NUMLOCK = &H90
Private Const VK_SCROLL = &H91
Private Type KeyboardBytes
kbByte(0 To 255) As Byte
End Type
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long)
As Long
Private Declare Function GetKeyboardState Lib "user32" (kbArray As
KeyboardBytes) As Long
Private Declare Function SetKeyboardState Lib "user32" (kbArray As
KeyboardBytes) As Long
Private kbArray As KeyboardBytes
Private Sub setKey(vkKey As Long, onVal As Boolean)
'Get the keyboard state
GetKeyboardState kbArray
'Change a key
kbArray.kbByte(vkKey) = Abs(onVal)
SetKeyboardState kbArray
End Sub
Private Function GetKeyStatus(vkKey As Long) As Boolean
'get the keyboard state
GetKeyboardState kbArray
'get and return the key state
GetKeyStatus = kbArray.kbByte(vkKey)
End Function
Public Property Get capsOn() As Boolean
capsOn = GetKeyStatus(VK_CAPITAL)
End Property
Public Property Let capsOn(ByVal bValue As Boolean)
setKey VK_CAPITAL, bValue
End Property
Public Property Get NumLockOn() As Boolean
capsOn = GetKeyStatus(VK_NUMLOCK)
End Property
Public Property Let NumLockOn(ByVal bValue As Boolean)
setKey VK_NUMLOCK, bValue
End Property
Public Property Get ScrollOn() As Boolean
capsOn = GetKeyStatus(VK_SCROLL)
End Property
Public Property Let ScrollOn(ByVal bValue As Boolean)
setKey VK_SCROLL, bValue
End Property
'* * * * * * * * * * *
'End CKeyboard Class Module
'* * * * * * * * * * *
--
Bobby C. Jones
http://www.acadx.com
keyboard...it toggles the capslock mode, but not the stupid light!!! Thanks
for your help.
'* * * * * * * * * * *
'Sample call
Public Sub testKB()
Dim oKeyboard As CKeyboard
Set oKeyboard = New CKeyboard
oKeyboard.capsOn = False
Set oKeyboard = Nothing
End Sub
'* * * * * * * * * * *
'CKeyboard Class Module
Option Explicit
Private Const VK_CAPITAL = &H14
Private Const VK_NUMLOCK = &H90
Private Const VK_SCROLL = &H91
Private Type KeyboardBytes
kbByte(0 To 255) As Byte
End Type
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long)
As Long
Private Declare Function GetKeyboardState Lib "user32" (kbArray As
KeyboardBytes) As Long
Private Declare Function SetKeyboardState Lib "user32" (kbArray As
KeyboardBytes) As Long
Private kbArray As KeyboardBytes
Private Sub setKey(vkKey As Long, onVal As Boolean)
'Get the keyboard state
GetKeyboardState kbArray
'Change a key
kbArray.kbByte(vkKey) = Abs(onVal)
SetKeyboardState kbArray
End Sub
Private Function GetKeyStatus(vkKey As Long) As Boolean
'get the keyboard state
GetKeyboardState kbArray
'get and return the key state
GetKeyStatus = kbArray.kbByte(vkKey)
End Function
Public Property Get capsOn() As Boolean
capsOn = GetKeyStatus(VK_CAPITAL)
End Property
Public Property Let capsOn(ByVal bValue As Boolean)
setKey VK_CAPITAL, bValue
End Property
Public Property Get NumLockOn() As Boolean
capsOn = GetKeyStatus(VK_NUMLOCK)
End Property
Public Property Let NumLockOn(ByVal bValue As Boolean)
setKey VK_NUMLOCK, bValue
End Property
Public Property Get ScrollOn() As Boolean
capsOn = GetKeyStatus(VK_SCROLL)
End Property
Public Property Let ScrollOn(ByVal bValue As Boolean)
setKey VK_SCROLL, bValue
End Property
'* * * * * * * * * * *
'End CKeyboard Class Module
'* * * * * * * * * * *
--
Bobby C. Jones
http://www.acadx.com