How to use SetKeyboardState function? 
Author Message
 How to use SetKeyboardState function?

Hi,I have a problem.
What is the argument need to pass to the SetKeyboardState function
and what is it's return value indicated?


Wed, 16 Jan 2002 03:00:00 GMT  
 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]



Wed, 16 Jan 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Problem using SetKeyboardState API call on Windows XP Pro

2. SetKeyboardState API Call

3. setkeyboardstate

4. SetKeyboardState to send Ctrl key combinations

5. Get/SetKeyboardState

6. setkeyboardstate

7. SetKeyboardState and caps lock

8. GetKeyState and SetKeyboardState

9. SetKeyboardState problem in NT

10. Executing Function using String Containing Function Name

11. Calling a sub or function using a variable through another sub or function

12. textwidth() function when text is to be printed using the tab() function

 

 
Powered by phpBB® Forum Software