viernes, 15 de enero de 2016

delphi copia portapapeles

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Memo1: TMemo;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  anterior: string;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.Clear;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
fic: textfile;
nuevo: boolean;
begin

timer1.Enabled:=false;

nuevo:=false;


if memo1.Text='' then
begin
  memo1.Clear;
  memo1.PasteFromClipboard;
 anterior:=memo1.Text;
 nuevo:=true;
end
else
begin

  memo1.Clear;
  memo1.PasteFromClipboard;

  if anterior<>memo1.Text then
  begin
    anterior:=memo1.Text;
    nuevo:=true;
  end;
end;

if nuevo=true then
begin

AssignFile (fic,'fondo.txt');
  if FileExists('fondo.txt')=false then
  begin
    ReWrite(fic);
  end
  else
  begin
    Append(fic);
  end;

Append(fic);
writeln(fic,memo1.Text);
CloseFile (fic);

end;


timer1.Enabled:=true;

end;

end.






.

No hay comentarios: