Показать сообщение отдельно
  #3  
Старый 14.10.2017, 13:42
nixon232 nixon232 вне форума
Активный
 
Регистрация: 26.01.2014
Сообщения: 282
Версия Delphi: delphi xe4
Репутация: выкл
По умолчанию

Код:
program Project1;

 {$APPTYPE GUI}

{$R *.res}

uses
  System.SysUtils, Vcl.Clipbrd,
 Winapi.Windows, Winapi.Messages;


    function GetCaretWindow: HWND;
 var
   w: HWND;
   aID, mID: DWORD;
   APoint: TPoint;
 begin
   Result:= 0;
   w:= GetForegroundWindow;
   if w <> 0 then
   begin
     aID:= GetWindowThreadProcessId(w, nil);
     mID:= GetCurrentThreadid;
     if (aID <> mID) then
      if AttachThreadInput(mID, aID, True) then
      try
        w:= GetFocus;
        if (w <> 0) then
          if GetCaretPos(APoint) then
          begin
            ClientToScreen(w, APoint);
            Result:=WindowFromPoint(APoint)
          end
      finally
        AttachThreadInput(mID, aID, False)
      end
   end
 end;

begin
Clipboard.AsText:='1234567890';
 PostMessage(GetCaretWindow,WM_PASTE,0,0);
     end.
Ответить с цитированием