Recent

Author Topic: [Solved] How to change CAPS LOCK status?  (Read 1789 times)

loaded

  • Hero Member
  • *****
  • Posts: 825
[Solved] How to change CAPS LOCK status?
« on: January 07, 2022, 06:44:08 am »
Hi All

With the code below, I change the Caps Lock state and switch to Caps Mode. No problem so far, But ;
-There is no change in the appearance of the Led light of Caps Lock.
-This change only affects my program, other programs in the system are not affected by it.
What do you think could be the reason and solution for this?

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. var
  3.   KeyState : TKeyboardState;
  4. begin
  5.   GetKeyboardState(KeyState);
  6.   if (KeyState[VK_CAPITAL] = 0) then
  7.   begin
  8.   KeyState[VK_CAPITAL] := 1;
  9.   SetKeyboardState(KeyState);
  10.   end;
  11. end;
« Last Edit: January 07, 2022, 07:50:00 am by loaded »
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

balazsszekely

  • Guest
Re: How to change CAPS LOCK status?
« Reply #1 on: January 07, 2022, 07:43:54 am »
Hi loaded,

Try this:
Code: Pascal  [Select][+][-]
  1. uses windows;
  2.  
  3. procedure TForm1.Button1Click(Sender: TObject);
  4. begin
  5.   keybd_event(VK_CAPITAL, 0, 0, 0);
  6.   keybd_event(VK_CAPITAL, 0, KEYEVENTF_KEYUP, 0);
  7. end;  

loaded

  • Hero Member
  • *****
  • Posts: 825
Re: How to change CAPS LOCK status?
« Reply #2 on: January 07, 2022, 07:49:42 am »
Thank you very much GetMem for the reply.
Yes, that's what I wanted.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

 

TinyPortal © 2005-2018