Hello
Does anyone know how can I get the status of Caps Lock; Num Loc;k Srcoll lock?
using access 2007.
Regards,
5 27962
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: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |