469,267 Members | 1,643 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,267 developers. It's quick & easy.

Caps Lock Num Lock Scroll lock status

222 100+
Hello


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


using access 2007.


Regards,
Oct 15 '08 #1
5 25798
ADezii
8,800 Expert 8TB
Just subscribing, but I'm pretty sure that you will need the API for this. Will return later, hopefully with an answer.
Oct 15 '08 #2
ADezii
8,800 Expert 8TB
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.
Oct 15 '08 #3
ADezii
8,800 Expert 8TB
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:
    Expand|Select|Wrap|Line Numbers
    1.  'Code from "VBA Developer's Handbook" (Sybex, 1997):
    2. Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) _
    3. As Integer
  2. Copy and Paste the following Functions into a Standard Code Module:
    Expand|Select|Wrap|Line Numbers
    1. Function GetCapslock() As Boolean
    2.   'Return the CapsLock Value
    3.   GetCapslock = CBool(GetKeyState(vbKeyCapital) And 1)
    4. End Function
    Expand|Select|Wrap|Line Numbers
    1. Function GetNumlock() As Boolean
    2.   'Return the NumLock Value
    3.   GetNumlock = CBool(GetKeyState(vbKeyNumlock) And 1)
    4. End Function
    Expand|Select|Wrap|Line Numbers
    1. Public Function GetScrollLock() As Boolean
    2.   'Return the ScrollLock Value
    3.   GetScrollLock = CBool(GetKeyState(&H91) And 1)
    4. End Function
  3. Sample Function Call(s):
    Expand|Select|Wrap|Line Numbers
    1. If GetCapslock() Then
    2.   MsgBox "Caps Lock is ON!"
    3. Else
    4.   MsgBox "Caps Lock is OFF!"
    5. End If
    6.  
    7. If GetNumlock() Then
    8.   MsgBox "Num Lock is ON!"
    9. Else
    10.   MsgBox "Num Lock is OFF!"
    11. End If
    12.  
    13. If GetScrollLock() Then
    14.   MsgBox "Scroll Lock is ON!"
    15. Else
    16.   MsgBox "Scroll Lock is OFF!"
    17. End If
Oct 15 '08 #4
wassimdaccache
222 100+
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:
    Expand|Select|Wrap|Line Numbers
    1.  'Code from "VBA Developer's Handbook" (Sybex, 1997):
    2. Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) _
    3. As Integer
  2. Copy and Paste the following Functions into a Standard Code Module:
    Expand|Select|Wrap|Line Numbers
    1. Function GetCapslock() As Boolean
    2.   'Return the CapsLock Value
    3.   GetCapslock = CBool(GetKeyState(vbKeyCapital) And 1)
    4. End Function
    Expand|Select|Wrap|Line Numbers
    1. Function GetNumlock() As Boolean
    2.   'Return the NumLock Value
    3.   GetNumlock = CBool(GetKeyState(vbKeyNumlock) And 1)
    4. End Function
    Expand|Select|Wrap|Line Numbers
    1. Public Function GetScrollLock() As Boolean
    2.   'Return the ScrollLock Value
    3.   GetScrollLock = CBool(GetKeyState(&H91) And 1)
    4. End Function
  3. Sample Function Call(s):
    Expand|Select|Wrap|Line Numbers
    1. If GetCapslock() Then
    2.   MsgBox "Caps Lock is ON!"
    3. Else
    4.   MsgBox "Caps Lock is OFF!"
    5. End If
    6.  
    7. If GetNumlock() Then
    8.   MsgBox "Num Lock is ON!"
    9. Else
    10.   MsgBox "Num Lock is OFF!"
    11. End If
    12.  
    13. If GetScrollLock() Then
    14.   MsgBox "Scroll Lock is ON!"
    15. Else
    16.   MsgBox "Scroll Lock is OFF!"
    17. End If
Prefect code.

Appreciate your time .

regards
Oct 16 '08 #5
ADezii
8,800 Expert 8TB
Prefect code.

Appreciate your time .

regards
Glad it worked for you.
Oct 16 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

18 posts views Thread by Robert | last post: by
4 posts views Thread by Peter D | last post: by
3 posts views Thread by Mike L | last post: by
2 posts views Thread by GSX | last post: by
4 posts views Thread by zacks | last post: by
1 post views Thread by goelvivek | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.