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]); keybd_event(w,0,0,0); keybd_event(w,0,KEYEVENTF_KEYUP,0); end; SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT,0,nil,0); SetForegroundWindow(ParentHwnd); SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT,D,nil,0); end;
procedure TForm1.Button1Click(Sender: TObject); begin WinExec('notepad.exe',SW_NORMAL); SendKeys(FindWindowEx(FindWindow('Notepad','Untitled - Notepad'),0,'Edit',''),'Your Text Here'); end;