473,669 Members | 2,504 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Caps Lock Num Lock Scroll lock status

222 New Member
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 28037
ADezii
8,834 Recognized Expert Expert
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 Recognized Expert Expert
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 Recognized Expert Expert
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 New Member
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 Recognized Expert Expert
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
4920
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 help. I have seen some example that looks at the characters entered in an input field to determine if the caps lock is on, but I was wondering if something is possible that is a bit more immediate to report the caps
4
6644
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 tell me why (the hell)it happens that way.
3
6636
by: Mike L | last post by:
How do I turn Caps Lock on, when my form opens?
2
2944
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 I cannot seem to find any info on how to retrieve their state. Thank you very much in advance.
1
15644
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 someone is interested, let me know and I will send you the codes). Once we know if the stat of Num Lock/ Caps Lock is not what we desired, we just send the Num Lock / Caps Lock key to change the stat. From most of
4
6009
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 UseSystemPasswordChar property is true, and the textbox has focus, if the Caps Lock key is pressed, a warning balloon tooltip is automatically displayed by the system. I cannot even find documentation that describes this behaviour. My question is,...
1
2839
by: goelvivek | last post by:
How can we get caps lock status in java. That it is on or off.
1
3156
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)) { MessageBox.Show("caps lock on"); }
0
8465
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8809
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8658
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2797
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.