Neautentificat.
Mentionez ca acest cod nu este facut de mine, eu am facut doar niste modificari pentru cazurile in care trebuie si Shift apasat.
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:
SendKeys(Notepad_handle, 'simulated text');
Offline
