» Utilizator
LAMP
» Parteneri» De citit» Recomandari» Taskuri securitate » Statistici
  • 65486 de mesaje.
  • 7732 de topicuri.
  • 1231 de utilizatori.
  •  
  • Kopotosa e ultimul utilizator inregistrat.
[Detalii]

 

| |
Pagini: [1]
Print

Simulare taste [Delphi] [1145 afisari]

DarkByte



Mesaje:

Mentionez ca acest cod nu este facut de mine, eu am facut doar niste modificari pentru cazurile in care trebuie si Shift apasat.

Code:
procedure SendKeys(WinHandle:Hwnd;Buffer:String);
var I: Integer;
    W: Word;
    D: DWORD;
    P: ^DWORD;
begin
  P:=@D;
  SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT,0,P,0);
  if IsIconic(WinHandle) then
    ShowWindow(WinHandle,SW_RESTORE);
  SetForegroundWindow(WinHandle);
  For I := 1 to Length(Buffer) do begin
    W:=VkKeyScan(Buffer[i]);
    if (Hi(w) and 1 = 1) then
      keybd_event(VK_SHIFT,1,0,0);
    keybd_event(w,0,0,0);
    keybd_event(w,0,KEYEVENTF_KEYUP,0);
    if (Hi(w) and 1 = 1) then
      keybd_event(VK_SHIFT,1,KEYEVENTF_KEYUP,0);
                                  end;
  SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT,0,nil,0);
  SetForegroundWindow(WinHandle);
  SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT,D,nil,0);
end;
Practic, doar alegeti fereastra (ca handle) in care vreti sa "scrieti" si ii dati ce text sa scrie.

Exemplu:
Code:
SendKeys(Notepad_handle, 'simulated text');
Logged
06-06-2008, 20:21 Twitt ::
Pagini: [1]
Print
SkullBox Forum  |  Development  |  Delphi & Pascal  |  Topic: Simulare taste [Delphi]