1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-24 02:02:17 -05:00

MML: SendKeys (win), Better way to do it.

This commit is contained in:
John P (Dgby714) 2011-07-23 18:00:23 -04:00
parent 3fbeab9a0b
commit 8acb244ec3

View File

@ -368,36 +368,29 @@ end;
procedure TWindow.SendString(str: string);
var
I, L: Integer;
K: Byte;
HoldShift: Boolean;
I, L: integer;
C: Byte;
ScanCode, VK: Word;
Shift: boolean;
begin
HoldShift := False;
L := Length(str);
for I := 1 to L do
begin
if (((str[I] >= 'A') and (str[I] <= 'Z')) or
((str[I] >= '!') and (str[I] <= '&')) or
((str[I] >= '(') and (str[I] <= '+')) or
(str[I] = ':') or
((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]);
HoldKey(K);
Sleep(20);
ReleaseKey(K);
if (HoldShift) then
begin
HoldShift := False;
ReleaseKey(VK_SHIFT);
end;
VK := VkKeyScan(str[I]);
Shift := (Hi(VK) > 0);
C := LoByte(VK);
ScanCode := MapVirtualKey(C, 0);
WriteLn(ScanCode);
if (Shift) then
Keybd_Event(VK_SHIFT, $2A, 0, 0);
Keybd_Event(C, ScanCode, 0, 0);
Keybd_Event(C, ScanCode, KEYEVENTF_KEYUP, 0);
if (Shift) then
Keybd_Event(VK_SHIFT, $2A, KEYEVENTF_KEYUP, 0);
end;
end;