UNIX,Linux,Retele,Programare

06 Jun 08 22:21

DarkByte
SkullBox Guardian
Locaţie: Lost in the Forgotten Realm...
Înregistrat: 23 Sep 06
Mesaje: 2117
Site web

Simulare taste [Delphi]



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

Cod:

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:

Cod:

SendKeys(Notepad_handle, 'simulated text');

Offline

 

» Failure is not an option, it's built-in

tutoriale unix,tutoriale linux,tutoriale bsd

Scuze de offtopic


38.103.63.61 <- te-am prins

Antet forum

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson



Ethical hacking and programming community