JoseCardoso
Programmer
- Mar 26, 2008
- 4
Hi,
I'm using some procedures (found in the Internet) to simulate a keystroke, but I can't send some special characters like "é", "ã", etc..
Unfortunately I need to write Portuguese names like “José”, “João”
Any idea how can I modify the SendKeys procedure to work it correctly ?
Thanks for help
Procedure SimulateKeyDown(Key: byte);
begin
keybd_event(Key, 0, 0, 0);
end;
procedure SimulateKeyUp(Key: byte);
begin
keybd_event(Key, 0, KEYEVENTF_KEYUP, 0);
end;
procedure SimulateKeystroke(Key: byte; extra: DWORD);
begin
keybd_event(Key, extra, 0, 0);
keybd_event(Key, extra, KEYEVENTF_KEYUP, 0);
end;
procedure SendKeys(s: string);
var
i: integer;
flag: bool;
w: word;
begin
flag := not GetKeyState(VK_CAPITAL) and 1 = 0;
if flag then SimulateKeystroke(VK_CAPITAL, 0);
for i := 1 to Length(s) do begin
w := VkKeyScan(s);
if ((HiByte(w) <> $FF) and (LoByte(w) <> $FF)) then begin
if HiByte(w) and 1 = 1 then SimulateKeyDown(VK_SHIFT);
SimulateKeystroke(LoByte(w), 0);
if HiByte(w) and 1 = 1 then SimulateKeyUp(VK_SHIFT)
end;
end;
if flag then SimulateKeystroke(VK_CAPITAL, 0);
end;
I'm using some procedures (found in the Internet) to simulate a keystroke, but I can't send some special characters like "é", "ã", etc..
Unfortunately I need to write Portuguese names like “José”, “João”
Any idea how can I modify the SendKeys procedure to work it correctly ?
Thanks for help
Procedure SimulateKeyDown(Key: byte);
begin
keybd_event(Key, 0, 0, 0);
end;
procedure SimulateKeyUp(Key: byte);
begin
keybd_event(Key, 0, KEYEVENTF_KEYUP, 0);
end;
procedure SimulateKeystroke(Key: byte; extra: DWORD);
begin
keybd_event(Key, extra, 0, 0);
keybd_event(Key, extra, KEYEVENTF_KEYUP, 0);
end;
procedure SendKeys(s: string);
var
i: integer;
flag: bool;
w: word;
begin
flag := not GetKeyState(VK_CAPITAL) and 1 = 0;
if flag then SimulateKeystroke(VK_CAPITAL, 0);
for i := 1 to Length(s) do begin
w := VkKeyScan(s);
if ((HiByte(w) <> $FF) and (LoByte(w) <> $FF)) then begin
if HiByte(w) and 1 = 1 then SimulateKeyDown(VK_SHIFT);
SimulateKeystroke(LoByte(w), 0);
if HiByte(w) and 1 = 1 then SimulateKeyUp(VK_SHIFT)
end;
end;
if flag then SimulateKeystroke(VK_CAPITAL, 0);
end;