Hello
Does anyone know how can I get the status of Caps Lock; Num Loc;k Srcoll lock?
using access 2007.
Regards,
5 27953
Just subscribing, but I'm pretty sure that you will need the API for this. Will return later, hopefully with an answer.
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.
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: - Copy and Paste the following Declaration intoma Standard Code Module:
- 'Code from "VBA Developer's Handbook" (Sybex, 1997):
-
Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) _
-
As Integer
- Copy and Paste the following Functions into a Standard Code Module:
- Function GetCapslock() As Boolean
-
'Return the CapsLock Value
-
GetCapslock = CBool(GetKeyState(vbKeyCapital) And 1)
-
End Function
- Function GetNumlock() As Boolean
-
'Return the NumLock Value
-
GetNumlock = CBool(GetKeyState(vbKeyNumlock) And 1)
-
End Function
- Public Function GetScrollLock() As Boolean
-
'Return the ScrollLock Value
-
GetScrollLock = CBool(GetKeyState(&H91) And 1)
-
End Function
- Sample Function Call(s):
- 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
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:- Copy and Paste the following Declaration intoma Standard Code Module:
- 'Code from "VBA Developer's Handbook" (Sybex, 1997):
-
Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) _
-
As Integer
- Copy and Paste the following Functions into a Standard Code Module:
- Function GetCapslock() As Boolean
-
'Return the CapsLock Value
-
GetCapslock = CBool(GetKeyState(vbKeyCapital) And 1)
-
End Function
- Function GetNumlock() As Boolean
-
'Return the NumLock Value
-
GetNumlock = CBool(GetKeyState(vbKeyNumlock) And 1)
-
End Function
- Public Function GetScrollLock() As Boolean
-
'Return the ScrollLock Value
-
GetScrollLock = CBool(GetKeyState(&H91) And 1)
-
End Function
- Sample Function Call(s):
- 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
Prefect code.
Appreciate your time .
regards
Glad it worked for you.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
by: Mike L |
last post by:
How do I turn Caps Lock on, when my form opens?
|
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...
|
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...
|
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...
|
by: goelvivek |
last post by:
How can we get caps lock status in java. That it is on or off.
|
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))
{
...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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
|
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...
|
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,...
|
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,...
|
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...
| |