SRL Archive - OSR Help

Storing highlighted text to a variable


shadowcon

2010-03-26 11:41:17

Is there any way in SCAR to store highlighted text (with the mouse) to a variable or store it to the clipboard?

Frement

2010-03-26 11:43:11

Well, using CTRL + C and CTRL + V yes.

i luffs yeww

2010-03-26 11:44:10

Yes there is. One second.


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.

Frement

2010-03-26 11:46:51

Like:
KeyDown(GetKeyCode('CTRL'));
KeyDown(GetKeyCode('C'));
KeyUp(GetKeyCode('CTRL'));
KeyUp(GetKeyCode('C'));

I dont know if the CTRL is valid thought.

shadowcon

2010-03-26 11:47:53

Okay thanks guys, gonna try KeyDown/KeyUp in a sec

edit: no, the ctrl wasn't valid :(

Frement

2010-03-26 11:50:19

Heres fixed version which should work:
program New;
begin
Wait(2000);
KeyDown(VK_CONTROL);
KeyDown(GetKeyCode('C'));
KeyUp(VK_CONTROL);
KeyUp(GetKeyCode('C'));
end.
I put the wait in there so i could select some text.

i luffs yeww

2010-03-26 11:51:26

Or you could do what I posted.

shadowcon

2010-03-26 11:52:27

Thanks! rep++
it works now :D

e: ty both of you :)

Quickmarch

2010-03-26 12:03:11

Use the 'SelText' property owned by the TEdit component to save highlighted text to a variable. ;)