Caps Lock Num Lock Scroll lock status

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wassimdaccache
    New Member
    • Apr 2007
    • 222

    #1

    Caps Lock Num Lock Scroll lock status

    Hello


    Does anyone know how can I get the status of Caps Lock; Num Loc;k Srcoll lock?


    using access 2007.


    Regards,
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Just subscribing, but I'm pretty sure that you will need the API for this. Will return later, hopefully with an answer.

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      Be advised that I have the required code to check the Status of the Num Lock, Caps Lock, and Scroll Lock Keys. I don't have the time right now, but I'll post it this evening along with an explanation.

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Here is the code that will accurately check the Status of the Num Lock, Caps Lock, and Scroll Lock Keys. Oddly enough, there appears to be no Intrinsic Constant for the Scroll Lock, so I simply passed its KeyCode Value (145) As a Hexadecimal Value to the Function and it worked. Here goes, this is a 3-Step process:
        1. Copy and Paste the following Declaration intoma Standard Code Module:
          Code:
           'Code from "VBA Developer's Handbook" (Sybex, 1997):
          Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) _
          As Integer
        2. Copy and Paste the following Functions into a Standard Code Module:
          Code:
          Function GetCapslock() As Boolean
            'Return the CapsLock Value
            GetCapslock = CBool(GetKeyState(vbKeyCapital) And 1)
          End Function
          Code:
          Function GetNumlock() As Boolean
            'Return the NumLock Value
            GetNumlock = CBool(GetKeyState(vbKeyNumlock) And 1)
          End Function
          Code:
          Public Function GetScrollLock() As Boolean
            'Return the ScrollLock Value
            GetScrollLock = CBool(GetKeyState(&H91) And 1)
          End Function
        3. Sample Function Call(s):
          Code:
          If GetCapslock() Then
            MsgBox "Caps Lock is ON!"
          Else
            MsgBox "Caps Lock is OFF!"
          End If
          
          If GetNumlock() Then
            MsgBox "Num Lock is ON!"
          Else
            MsgBox "Num Lock is OFF!"
          End If
          
          If GetScrollLock() Then
            MsgBox "Scroll Lock is ON!"
          Else
            MsgBox "Scroll Lock is OFF!"
          End If

        Comment

        • wassimdaccache
          New Member
          • Apr 2007
          • 222

          #5
          Originally posted by ADezii
          Here is the code that will accurately check the Status of the Num Lock, Caps Lock, and Scroll Lock Keys. Oddly enough, there appears to be no Intrinsic Constant for the Scroll Lock, so I simply passed its KeyCode Value (145) As a Hexadecimal Value to the Function and it worked. Here goes, this is a 3-Step process:
          1. Copy and Paste the following Declaration intoma Standard Code Module:
            Code:
             'Code from "VBA Developer's Handbook" (Sybex, 1997):
            Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) _
            As Integer
          2. Copy and Paste the following Functions into a Standard Code Module:
            Code:
            Function GetCapslock() As Boolean
              'Return the CapsLock Value
              GetCapslock = CBool(GetKeyState(vbKeyCapital) And 1)
            End Function
            Code:
            Function GetNumlock() As Boolean
              'Return the NumLock Value
              GetNumlock = CBool(GetKeyState(vbKeyNumlock) And 1)
            End Function
            Code:
            Public Function GetScrollLock() As Boolean
              'Return the ScrollLock Value
              GetScrollLock = CBool(GetKeyState(&H91) And 1)
            End Function
          3. Sample Function Call(s):
            Code:
            If GetCapslock() Then
              MsgBox "Caps Lock is ON!"
            Else
              MsgBox "Caps Lock is OFF!"
            End If
            
            If GetNumlock() Then
              MsgBox "Num Lock is ON!"
            Else
              MsgBox "Num Lock is OFF!"
            End If
            
            If GetScrollLock() Then
              MsgBox "Scroll Lock is ON!"
            Else
              MsgBox "Scroll Lock is OFF!"
            End If
          Prefect code.

          Appreciate your time .

          regards

          Comment

          • ADezii
            Recognized Expert Expert
            • Apr 2006
            • 8834

            #6
            Originally posted by wassimdaccache
            Prefect code.

            Appreciate your time .

            regards
            Glad it worked for you.

            Comment

            Working...