1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
//Procedures pour simuler l'appui de touches -DEBUT
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)=1;
if flag then SimulateKeystroke(VK_CAPITAL, 0);
for i :=1 to Length(s) do
begin w := VkKeyScan(s[i]);
if ((HiByte(w) <> $FF) and (LoByte(w) <> $FF))
then begin
if HiByte(w)=1
then SimulateKeyDown(VK_SHIFT);
SimulateKeystroke(LoByte(w), 0);
if HiByte(w)=1
then SimulateKeyUp(VK_SHIFT);
end;
end;
if flag then SimulateKeystroke(VK_CAPITAL, 0);
end;
//Procedures pour simuler l'appui de touches -FIN
begin
//1- Met le Focus "clavier" sur la fenètre spécifiée
SetFocus(UnHandleDeFenetrte);
//2 - Envoi des codes touches
SendKeys('Coucou');
SimulateKeystroke(VK_RETURN, 0);
end; |
Partager