mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-24 10:12:20 -05:00
MML: SendKeys (win), Better way to do it.
This commit is contained in:
parent
3fbeab9a0b
commit
8acb244ec3
@ -368,36 +368,29 @@ end;
|
|||||||
|
|
||||||
procedure TWindow.SendString(str: string);
|
procedure TWindow.SendString(str: string);
|
||||||
var
|
var
|
||||||
I, L: Integer;
|
I, L: integer;
|
||||||
K: Byte;
|
C: Byte;
|
||||||
HoldShift: Boolean;
|
ScanCode, VK: Word;
|
||||||
|
Shift: boolean;
|
||||||
begin
|
begin
|
||||||
HoldShift := False;
|
|
||||||
L := Length(str);
|
L := Length(str);
|
||||||
for I := 1 to L do
|
for I := 1 to L do
|
||||||
begin
|
begin
|
||||||
if (((str[I] >= 'A') and (str[I] <= 'Z')) or
|
VK := VkKeyScan(str[I]);
|
||||||
((str[I] >= '!') and (str[I] <= '&')) or
|
Shift := (Hi(VK) > 0);
|
||||||
((str[I] >= '(') and (str[I] <= '+')) or
|
C := LoByte(VK);
|
||||||
(str[I] = ':') or
|
ScanCode := MapVirtualKey(C, 0);
|
||||||
((str[I] >= '<') and (str[I] <= '@')) or
|
|
||||||
((str[I] >= '^') and (str[I] <= '_')) or
|
|
||||||
((str[I] >= '{') and (str[I] <= '~'))) then
|
|
||||||
begin
|
|
||||||
HoldKey(VK_SHIFT);
|
|
||||||
HoldShift := True;
|
|
||||||
end;
|
|
||||||
|
|
||||||
K := GetKeyCode(str[I]);
|
WriteLn(ScanCode);
|
||||||
HoldKey(K);
|
|
||||||
Sleep(20);
|
|
||||||
ReleaseKey(K);
|
|
||||||
|
|
||||||
if (HoldShift) then
|
if (Shift) then
|
||||||
begin
|
Keybd_Event(VK_SHIFT, $2A, 0, 0);
|
||||||
HoldShift := False;
|
|
||||||
ReleaseKey(VK_SHIFT);
|
Keybd_Event(C, ScanCode, 0, 0);
|
||||||
end;
|
Keybd_Event(C, ScanCode, KEYEVENTF_KEYUP, 0);
|
||||||
|
|
||||||
|
if (Shift) then
|
||||||
|
Keybd_Event(VK_SHIFT, $2A, KEYEVENTF_KEYUP, 0);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user