Virtual keyboard
- From: "Sanyin" <sasasa>
- Date: Tue, 30 Jan 2007 10:58:26 +0100
i made some kind of virtual keyboard, to use it just in my application, not
in global like windows on screen keyboard.
when press button, depenging on key kind, i get keyboard virtualkey
(shift,ctrl.etc) or scancode (other keys).
to get unicode keys for EVERY international keyboard i have used this:
function TKey.GetCharFromScanCode(sc: byte; CapsDown, ShiftDown, CtrlDown,
AltDown, AltGrDown: boolean; klayout: hkl): widestring;
var
ks: tkeyboardstate;
len: Integer;
vk: word;
r: widestring;
begin
getkeyboardstate(ks);
if shiftdown then
ks[VK_SHIFT] := $81
else
ks[VK_SHIFT] := 0;
if CtrlDown then
ks[VK_CONTROL] := $81
else
ks[VK_CONTROL] := 0;
if AltDown then
begin
ks[VK_MENU] := $81;
ks[VK_MENU] := $81;
end
else
begin
ks[VK_MENU] := 0;
ks[VK_MENU] := 0;
end;
if capsdown then
ks[VK_CAPITAL] := $81
else
ks[VK_CAPITAL] := 0;
if AltGrDown then
begin
ks[VK_CONTROL] := $81;
ks[VK_MENU] := $81;
end;
vk := mapvirtualkeyexw(sc, 1, klayout);
SetLength(r, 5);
r := #0#0#0#0#0#0#0#0#0#0;
len := tounicode(vk, sc, ks, PWideChar(r)^, 5, 1);
if len >= 1 then
begin
SetLength(result, len);
result := copy(r, 1, len);
end
else if len = -1 then //dead char
begin
SetLength(result, 1);
result := copy(r, 1, 1);
tounicode(vk, sc, (ks), PWideChar(r)^, 5, 0); //ponisti dead char (da se
ne 'pokaze' sljedeci put)
end;
end;
i have created thread that sends input when i press key.
procedure TSendInputThread.Add(var r: tinputrec);
var t: ptinputrec;
begin
if terminated then
exit;
criticalobject.Acquire;
try
new(t);
t^ := r;
tlist(list).Add(t);
finally
criticalobject.Release;
end;
end;
procedure TSendInputThread.Execute;
begin
while not terminated do
begin
if (list <> nil) and (tlist(list).Count > 0) then
begin
criticalobject.Acquire;
try
try
SendInput(length(pTInputRec(tlist(list).items[0])^.arr),
pTInputRec(tlist(list).items[0])^.arr[0], sizeof(tinput));
setlength(pTInputRec(tlist(list).items[0])^.arr, 0);
dispose(tlist(list).items[0]);
tlist(list).Delete(0);
except
end;
finally
criticalobject.Release;
end;
end;
sleep(1);
end;
end;
problem is this:
i need to make control (tmemo) to catch these keys, in other words how to
get text that i need to display?
.
- Follow-Ups:
- Re: Virtual keyboard
- From: Sanyin
- Re: Virtual keyboard
- Prev by Date: Re: WPTools
- Next by Date: Re: Virtual keyboard
- Previous by thread: WPTools
- Next by thread: Re: Virtual keyboard
- Index(es):