Einzelnen Beitrag anzeigen

fadz

Registriert seit: 27. Nov 2004
41 Beiträge
 
#15

Re: string in ein beliebiges fenster schreiben

  Alt 18. Feb 2005, 15:25
Delphi-Quellcode:
procedure tform1.test;
var
FocusHWnd: HWND;
AppHWnd: HWND;
ThreadId: DWORD;
WndText: String;
begin
FocusHWnd := GetFocus;
  if not IsWindow(FocusHWnd) then
  begin
    AppHWnd := GetForegroundWindow;
    if AppHWnd <> Self.Handle then
    begin
      ThreadId := GetWindowThreadProcessId(AppHWnd, nil);
      if ThreadId <> 0 then
        if AttachThreadInput(GetCurrentThreadId, ThreadId, True) then
        begin
          FocusHWnd := GetFocus;
          AttachThreadInput(GetCurrentThreadId, ThreadId, False);
        end;
    end;
  end;
wndtext:='hallo';
//FocusHWnd := GetForegroundWindow;
SendMessage(FocusHWnd, WM_SETTEXT, Length(WndText), LPARAM(PChar(WndText)));
end;
  Mit Zitat antworten Zitat