• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

Caps lock on/off

How do I turn Caps lock, scroll lock and num lock on or off
0
koger
Asked:
koger
  • 3
  • 2
1 Solution
 
ronit051397Commented:
Here is some code:

procedure TForm1.Button1Click(Sender: TObject);
begin
IF GetKeyState(VK_CAPITAL)=0 THEN showmessage('Caps lock is Off');//1=ON
IF GetKeyState(VK_NUMLOCK)=0 THEN showmessage('Num lock is Off');
IF GetKeyState(VK_SCROLL)=0 THEN showmessage('Scroll lock is Off');
//we send key accelerators
keybd_event(VK_CAPITAL,0,0,0);
keybd_event(VK_CAPITAL,0,KEYEVENTF_KEYUP,0);
keybd_event(VK_NUMLOCK,0,0,0);
keybd_event(VK_NUMLOCK,0,KEYEVENTF_KEYUP,0);
keybd_event(VK_SCROLL,0,0,0);
keybd_event(VK_SCROLL,0,KEYEVENTF_KEYUP,0);
end;

0
 
kogerAuthor Commented:
I don't seem to get the code to work properly in Win95, but under Win NT, it works great, do you have a clue why this doesn't work.
0
 
ronit051397Commented:
I have also tested it under WinNT. As for Win95 I'll Check.
0
 
ronit051397Commented:
I checked on win95 and only the numlock didn't work but the others did. I Don't know why this is happening.
0
 
kogerAuthor Commented:
The same happent to me, guees thats just the Win95 is, I will try asking some Win95 experts, thanks for your help.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now