
How to use SetKeyboardState function?
Hi Iwneo,
Quote:
> What is the argument need to pass to the SetKeyboardState function
> and what is it's return value indicated?
Parameters
lpbKeyState Points to a 256-byte array that contains keyboard key states.
Return Value
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE. To get extended error
information, call GetLastError.
Example with CapsLock:
Public Function SetCapsLock(SetToOn As Boolean) As Boolean
Dim KeyStatusBuf(0 To 255) As Byte
Dim bRetVal As Boolean
' Get the status of all virtual keys
bRetVal = GetKeyboardState(KeyStatusBuf(0))
If bRetVal = False Then ' Error
SetCapsLock = False
Exit Function
End If
' Set the new value
If SetToOn = True Then
KeyStatusBuf(VK_CAPITAL) = 1
Else
KeyStatusBuf(VK_CAPITAL) = 0
End If
' Set the new status
bRetVal = SetKeyboardState(KeyStatusBuf(0))
If bRetVal = False Then ' Error
SetCapsLock = False
Exit Function
End If
' Return value
SetCapsLock = True
End Function
--
???
Mayk
--
[Win98, VB5, SP3]