473,387 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 27953
ADezii
8,834 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,834 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,834 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,834 Expert 8TB
Prefect code.

Appreciate your time .

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

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

Similar topics

18
by: Robert | last post by:
Hi! I was wondering if the was any way to determine the state of the caps lock key, on or off. Of course I can capture the key events and see whether the caps lock is pressed, but that does not...
4
by: Peter D | last post by:
I have a second hand bar code reader (keyboard wedge) en i can read the bar codes but after every scan he turns my caps lock on. (GRRRRRR). I search a code to turn my caps lock off or can anyone...
3
by: Mike L | last post by:
How do I turn Caps Lock on, when my form opens?
2
by: GSX | last post by:
Would somebody be able to point me in the direction of figuring out how to determine if Caps Lock is on, Num Lock is on, INS or OVR, etc.? I'm looking to display their status in a statusbar, but...
1
by: charlies224 | last post by:
Hi, I am writting a software that requires me to make sure the Num Lock is always on and Caps Lock is always off. First, I know how to detect if Num Lock or Caps Lock is on or off (if...
4
by: zacks | last post by:
I'm not sure when it came into being, since this it the first time I have worked very much with a password control in .NET, but if a textbox that has a non-empty value for PasswordChar or the...
1
by: goelvivek | last post by:
How can we get caps lock status in java. That it is on or off.
1
by: cmrhema | last post by:
Hi, Two questions 1. In windows application if we put on the below code, it will identify whether caps lock is on or not if (TextBox.IsKeyLocked(Keys.CapsLock)) { ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.