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

How to switch Keyboard indicator ?

I would like to switch windows keyboard indicator in traybar.
How to send a message ?

thanks for advance
0
tong111797
Asked:
tong111797
1 Solution
 
JamesLondonCommented:

The following example toggles the Num-Lock Keyboard Light on and off. Just Change VK_NUMLOCK to the one you want...


if Odd(GetAsyncKeyState( VK_NUMLOCK )) <> True Then
  begin
    keybd_event(VK_NUMLOCK, MapVirtualkey(VK_NUMLOCK, 0), KEYEVENTF_EXTENDEDKEY, 0);
    keybd_event(VK_NUMLOCK, MapVirtualkey(VK_NUMLOCK, 0), KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0);
  End;

Best Regards,
James
0
 
khalil_moghaddamCommented:
Hi tong!

use LoadKeyboardLayout API, See Delphi help for example
0
 
tong111797Author Commented:
I found the solution.

var
  hklEN      : HKL;
  hklTH      : HKL;

procedure TForm1.FormCreate(Sender: TObject);
begin
  hklEN := LoadKeyboardLayout('00000409',0);
  hklTH := LoadKeyboardLayout('0000041E',0);
end;


in my procedure switch it by

     Handle := GetFocus;
     SendMessage(Handle,WM_INPUTLANGCHANGEREQUEST,0,hklTH);
or
     SendMessage(Handle,WM_INPUTLANGCHANGEREQUEST,0,hklEN);


0
 
Computer101Commented:
Points refunded and placed in PAQ

Computer101
E-E Admin
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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