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:
parent
3fbeab9a0b
commit
8acb244ec3
@ -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;
|
||||
VK := VkKeyScan(str[I]);
|
||||
Shift := (Hi(VK) > 0);
|
||||
C := LoByte(VK);
|
||||
ScanCode := MapVirtualKey(C, 0);
|
||||
|
||||
K := GetKeyCode(str[I]);
|
||||
HoldKey(K);
|
||||
Sleep(20);
|
||||
ReleaseKey(K);
|
||||
WriteLn(ScanCode);
|
||||
|
||||
if (HoldShift) then
|
||||
begin
|
||||
HoldShift := False;
|
||||
ReleaseKey(VK_SHIFT);
|
||||
end;
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user