Results 1 to 8 of 8

Thread: Return Text From Clipboard

  1. #1
    Join Date
    Dec 2007
    Location
    Wizzup?'s boat
    Posts
    1,013
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Return Text From Clipboard

    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.

    SCAR Code:
    thetext = GetClipboard;
    thetext = Copy(...);
    writeln(thetext);
    Project: Welcome To Rainbow

  2. #2
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    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.

  3. #3
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    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.
    Interested in C# and Electrical Engineering? This might interest you.

  4. #4
    Join Date
    Jun 2007
    Location
    #SRL
    Posts
    200
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    SCAR Code:
    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.
    Quote Originally Posted by IRC
    <Wizzup> 5
    <Wizzup> 4
    <Wizzup> 43
    <Wizzup> shit
    <Wizzup> 5
    <Wizzup> 4
    <Wizzup> 3
    <Wizzup> 1
    <Wizzup> offblast

  5. #5
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Without making a form:
    scar Code:
    function getClipboardText: String;
    var
      RE : TRichEdit;
    begin
      RE := TRichEdit.Create(nil);
      RE.PasteFromClipboard;
      Result := RE.Lines.Text;
      RE.Free;
    end;
    Last edited by Cazax; 04-16-2009 at 05:26 AM.


  6. #6
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Cazax View Post
    Without making a form:
    scar Code:
    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.

  7. #7
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

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


  8. #8
    Join Date
    Dec 2007
    Location
    Wizzup?'s boat
    Posts
    1,013
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

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

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

    Thanks everyone
    Project: Welcome To Rainbow

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •