14.10.2017, 13:42
|
Активный
|
|
Регистрация: 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.
|