Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Toggle Caps lock

Posted on 1997-05-26
1
Medium Priority
?
471 Views
Last Modified: 2010-04-04
How do I toggle Caps lock on/off
0
Comment
Question by:Jens204
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
erajoj earned 40 total points
ID: 1336594
This code will toggle the CapsLock state in NT/Win95:

procedure TMainForm.Button10Click(Sender: TObject);
Var
  KeyState  :  TKeyboardState;
begin
  GetKeyboardState(KeyState); {Only to check current state}
  keybd_event( VK_CAPITAL, $45, KEYEVENTF_EXTENDEDKEY, 0 );
  keybd_event( VK_CAPITAL, $45, KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0);
end;

To find out if CapsLock is on then check KeyState[VK_CAPITAL].
(0=off/1=on)
--------------------------------------------------------------
This code will toggle the CapsLock state in Windows 3.x:

procedure TMainForm.Button10Click(Sender: TObject);
Var
  KeyState  :  TKeyboardState;
begin
  GetKeyboardState(KeyState);
  KeyState[VK_CAPITAL] := KeyState[VK_CAPITAL] xor 1;
  SetKeyboardState(KeyState);
end;

This will also work with VK_NUMLOCK.

Enjoy!

/// John

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question