Results 1 to 12 of 12

Thread: [2008] turn on off caps lock

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    262

    Resolved [2008] turn on off caps lock

    Banging my head all morning about this, as seems to be something you cannot do without calling windows api functions.
    Have scraped over the internet and come up with this

    h Code:
    1. Private Sub Button6_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
    2.         SetKeyState(System.Windows.Forms.Keys.CapsLock, True)
    3.  
    4.     End Sub
    5.  
    6.     Private Declare Auto Function SetKeyboardState Lib "user32.dll" _
    7.       (ByVal lppbKeyState As Byte) As Long
    8.     Private Declare Auto Function GetKeyState Lib "user32.dll" _
    9.       (ByVal nVirtKey As Long) As Boolean
    10.     Private Declare Auto Function GetKeyboardState Lib "user32.dll" _
    11.         (ByVal pbKeyState As Byte) As Long
    12.  
    13.      Private Sub SetKeyState(ByVal Key As Long, ByVal State As Boolean)
    14.  
    15.         Dim Keys(0 To 255) As Byte
    16.         Call GetKeyboardState(Keys(0))
    17.         Keys(Key) = Math.Abs(CInt(State))
    18.         Call SetKeyboardState(Keys(0))
    19.  
    20.     End Sub

    But it doesn't work and am well out of my depth.
    I just want to check if caps lock is pressed and if so turn it off.
    Any help would be greatly appreciated.
    Last edited by Oliver1; Sep 1st, 2008 at 05:53 AM. Reason: esolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width