Solved

Toggle Caps lock

Posted on 1997-05-26
1
469 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 20 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month4 days, 18 hours left to enroll

636 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