Solved

Toggle Caps lock

Posted on 1997-05-26
1
458 Views
Last Modified: 2010-04-04
How do I toggle Caps lock on/off
0
Comment
Question by:Jens204
1 Comment
 
LVL 4

Accepted Solution

by:
erajoj earned 20 total points
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now