Skip to content

Commit

Permalink
Merge pull request #3 from Sv-Vik/master
Browse files Browse the repository at this point in the history
переключение языка (реестр)
  • Loading branch information
Pr-Mex authored Nov 11, 2019
2 parents c2ea7f2 + 5192429 commit 3a3cf3c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
Binary file modified KeyboardType/Unit1.dcu
Binary file not shown.
51 changes: 46 additions & 5 deletions KeyboardType/Unit1.pas
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ClipBrd, ExtCtrls, StrUtils;
Dialogs, StdCtrls, ClipBrd, ExtCtrls, StrUtils, Registry;

type
TForm1 = class(TForm)
Expand Down Expand Up @@ -48,6 +48,7 @@ TMyClipboard = class(TClipboard);
glID:integer;
glTekLan:string;
gltypespeed:integer;
switchLangAltShift: boolean;

implementation

Expand Down Expand Up @@ -76,6 +77,38 @@ function ItsRussianLetter(S:String):boolean;

end;

function ItsSwitchLangAltShift():boolean;
var
Reestr: TRegistry;
Param: String;
begin
result:=false;
Reestr:=TRegistry.Create;
Reestr.RootKey:=HKEY_CURRENT_USER;
If Reestr.OpenKey('\Keyboard Layout\Toggle', False) Then
Begin
Param := Reestr.ReadString('Hotkey');
If Param = '1' Then
result:=true
Else
result:=false;

Reestr.CloseKey;
End;

Reestr.Free;

end;

procedure DoAltShift();
begin
keybd_event(VK_MENU, 0, 0, 0);
keybd_event(VK_LSHIFT, 0, 0, 0);
sleep(10);
keybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
sleep(100);
end;

procedure DoCtrlShift();
begin
Expand All @@ -88,19 +121,28 @@ procedure DoCtrlShift();
end;


procedure DoSwitchLang();

begin
If switchLangAltShift Then
DoAltShift
Else
DoCtrlShift;

end;

procedure FullSwitchEng();
begin
LoadKeyboardLayout(PChar('00000409'), KLF_ACTIVATE);
DoCtrlShift;
DoSwitchLang;
glTekLan:='en';
end;


procedure FullSwitchRus();
begin
LoadKeyboardLayout(PChar('00000419'), KLF_ACTIVATE);
DoCtrlShift;
DoSwitchLang;
glTekLan:='ru';
end;

Expand All @@ -126,7 +168,6 @@ procedure SimulateKeystroke(Key : byte; extra : DWORD);
end;



procedure SendKeysHome();
var
i : integer;
Expand Down Expand Up @@ -684,7 +725,7 @@ procedure TForm1.FormCreate(Sender: TObject);

gltypespeed:=100;
filename:='';

switchLangAltShift:= ItsSwitchLangAltShift();

for i := 1 to ParamCount do
begin
Expand Down

0 comments on commit 3a3cf3c

Please sign in to comment.