1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| unit app2unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, Windows, Clipbrd;
const
MY_MESSAGE = WM_USER + 1000; // le même message que dans l'application 1
type
TApp2Form = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
App2Form: TApp2Form;
implementation
{$R *.lfm}
procedure TApp2Form.Button1Click(Sender: TObject);
// à remplacer par KeyDown F6
var
H: HWND;
S: string;
begin
H:= FindWindow(nil, PChar('app1form'));
if H <> 0 then
begin
PostMessage(H, MY_MESSAGE,0,0); // 0,0 à remplacer par valeurs x,y
Sleep(500); // un peu d'attente
S:= Clipboard.AsText; // récupération du presse-papier
Showmessage(S);
end;
end;
end. |
Partager