SRL Archive - Other Scripts

Return Text From Clipboard


benjaa

2009-04-14 19:38:02

Someone made me a procedure once to retrieve a string from clipboard, but i lost it.

It had something about "Safe" in it, as a function. I have no idea what that is.

But could someone please write my a function to return the text in Clipboard?

(don't say Keydown(<control>) + Keydown("v") because i need it to be internal)

eg.

thetext = GetClipboard;
thetext = Copy(...);
writeln(thetext);

senrath

2009-04-15 07:19:25

Well, it's sort of a function that I wrote. I'm not sure how to do it in pure SCAR, so I wrote a plug-in with Delphi.

http://rapidshare.com/files/221475037/ScarClipboard.zip

I would've attached it, but it was too big. Anyway, both the dll and source are included. The single function added is TextFromClipboard which returns a string of whatever is in the clipboard.

Smartzkid

2009-04-15 08:12:45

The procedure you want is TMemo.PasteFromClipboard. You'll need to set everything up just like you would in a normal form, just don't show the form.

I'll try to remember to check this thread, but if I don't and you need help, feel free to PM me.

Tootoot222

2009-04-15 11:21:49

program CopyPasta;
var
F: TForm;
E: TEdit;

procedure InitForm;
begin
F:= CreateForm;
E:= TEdit.Create(F);
with E do
begin
Parent:= F;
PasteFromClipboard;
Writeln(Text);
end;
end;

procedure SafeInitForm;
var
V: TVariantArray;
begin
V:= [];
ThreadSafeCall('InitForm', V);
end;

begin
SafeInitForm;
end.

Cazax

2009-04-16 01:11:28

Without making a form:
function getClipboardText: String;
var
RE : TRichEdit;
begin
RE := TRichEdit.Create(nil);
RE.PasteFromClipboard;
Result := RE.Lines.Text;
RE.Free;
end;

bullzeye95

2009-04-16 01:20:13

From: Cazax
Without making a form:
function getClipboardText: String;
var
RE : TRichEdit;
begin
RE := TRichEdit1.Create(nil);
RE.PasteFromClipboard;
Result := RE.Lines.Text;
RE.Free;
end;


That won't work. The richedit needs to have a parent.

Cazax

2009-04-16 01:29:48

Ok, I thought it would work. what toot made should solve the problem.

benjaa

2009-04-16 10:33:36

Thanks Senrath, but i think i'll go with Tootoot's..

I'm not a fan of anything external - it gets messy

Thanks everyone :)