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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
procedure TFormSW.SimulateKeyDown(Key : byte);
begin
keybd_event(Key, 0, 0, 0);
end;
procedure TFormSW.SimulateKeyUp(Key : byte);
begin
keybd_event(Key, 0, KEYEVENTF_KEYUP, 0);
end;
procedure TFormSW.SimulateKeystroke(Key : byte; extra : DWORD);
begin
keybd_event(Key, extra, 0, 0);
keybd_event(Key, extra, KEYEVENTF_KEYUP, 0);
end;
procedure TFormSW.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
procedure TFormSW.BitBtn1Click(Sender: TObject);
var reponse : string;
begin
with BDDModule do begin
//ShellExecute(0,'open',PChar('yop'),nil,nil,SW_SHOW);
ShellExecute(0,'open',PChar('cmd'),nil,'P:\',SW_SHOW);
Sleep(100); //petit temps d'attente
//SendKeys(#64);
//SimulateKeystroke(VK_RETURN, 0);
SendKeys('plink.exe -ssh ldapsup');
SimulateKeyDown(VK_CONTROL);
SimulateKeyDown(VK_MENU);
SendKeys('à');
SimulateKeyUp(VK_MENU);
SimulateKeyUp(VK_CONTROL);
SendKeys('cat');
SimulateKeystroke(VK_RETURN, 0);
Sleep(10); //petit temps d'attente
SendKeys('catseyes');
SimulateKeystroke(VK_RETURN, 0);
Sleep(5000);
SendKeys('cd tom');
SimulateKeystroke(VK_RETURN, 0);
Sleep(100);
SendKeys('go');
SimulateKeystroke(VK_RETURN, 0);
Sleep(200);
SendKeys('1');
SimulateKeystroke(VK_RETURN, 0);
Sleep(100);
SendKeys(MID_Query.Fields.Fields[2].AsString);
SimulateKeystroke(VK_RETURN, 0);
end; |
Partager