1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-12-03 22:22:19 -05:00

Merge pull request #31 from Dgby714/SendKeysFix

MML: SendKeys
This commit is contained in:
Merlijn Wajer 2011-07-23 15:08:58 -07:00
commit 38c8b16407
2 changed files with 55 additions and 49 deletions

View File

@ -413,34 +413,40 @@ implementation
result := xmask and ButtonP > 0; result := xmask and ButtonP > 0;
end; end;
procedure TWindow.SendString(str: string); procedure TWindow.SendString(str: string);
var var
i: integer; I, L: Integer;
key: byte; K: Byte;
HoldShift : boolean; HoldShift: Boolean;
begin
HoldShift := False;
L := Length(str);
for I := 1 to L do
begin begin
HoldShift := false; if (((str[I] >= 'A') and (str[I] <= 'Z')) or
for i := 1 to length(str) do ((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 begin
if((str[i] >= 'A') and (str[i] <= 'Z')) then HoldKey(VK_SHIFT);
begin HoldShift := True;
HoldKey(VK_SHIFT);
HoldShift:= True;
str[i] := lowerCase(str[i]);
end else
if HoldShift then
begin
HoldShift:= false;
ReleaseKey(VK_SHIFT);
end;
key:= GetKeyCode(str[i]);
HoldKey(key);
//BenLand100: You should probably wait here...
ReleaseKey(key);
end; end;
if HoldShift then
K := GetKeyCode(str[I]);
HoldKey(K);
Sleep(20);
ReleaseKey(K);
if (HoldShift) then
begin
HoldShift := False;
ReleaseKey(VK_SHIFT); ReleaseKey(VK_SHIFT);
end;
end; end;
end;
procedure TWindow.HoldKey(key: integer); procedure TWindow.HoldKey(key: integer);
begin begin

View File

@ -366,34 +366,34 @@ begin
end; end;
end; end;
procedure TWindow.SendString(str: string); procedure TWindow.SendString(str: string);
var var
i: integer; I, L: integer;
key: byte; C: Byte;
HoldShift : boolean; ScanCode, VK: Word;
Shift: boolean;
begin
L := Length(str);
for I := 1 to L do
begin begin
HoldShift := false; VK := VkKeyScan(str[I]);
for i := 1 to length(str) do Shift := (Hi(VK) > 0);
begin C := LoByte(VK);
if((str[i] >= 'A') and (str[i] <= 'Z')) then ScanCode := MapVirtualKey(C, 0);
begin if (ScanCode = 0) then
HoldKey(VK_SHIFT); Continue;
HoldShift:= True;
str[i] := lowerCase(str[i]); if (Shift) then
end else Keybd_Event(VK_SHIFT, $2A, 0, 0);
if HoldShift then
begin Keybd_Event(C, ScanCode, 0, 0);
HoldShift:= false; Keybd_Event(C, ScanCode, KEYEVENTF_KEYUP, 0);
ReleaseKey(VK_SHIFT);
end; if (Shift) then
key:= GetKeyCode(str[i]); Keybd_Event(VK_SHIFT, $2A, KEYEVENTF_KEYUP, 0);
HoldKey(key);
//BenLand100 note: probably should wait here
ReleaseKey(key);
end;
if HoldShift then
ReleaseKey(VK_SHIFT);
end; end;
end;
procedure TWindow.HoldKey(key: integer); procedure TWindow.HoldKey(key: integer);
begin begin
keyinput.Down(key); keyinput.Down(key);