How to add multiple lines to the clipboard... 
Author Message
 How to add multiple lines to the clipboard...

Hi,

How do I add text (multiple lines)to the Windows Clipboard..
I have the following program...

#!perl

use Win32::Clipboard;

my $String = "Hello World\nHow are You?\n";
print "$String";
Win32::Clipboard::Set($String);

Whe I run this script:
The output generated on the screen...

Hello World
How are You?

But the data that is present in the clipboard is "Hello WorldHow are You?"
This I get in the Windows Notepad, but in the MS Word I get two lines.

Would appreciate if anyone could point out how to add a DOS NewLine in the
Clipboard - maybe we need to add one more char other than "\n"

Thanks in advance.
Shyam.



Mon, 21 Nov 2005 19:38:52 GMT  
 How to add multiple lines to the clipboard...

Quote:

> How do I add text (multiple lines)to the Windows Clipboard.. I have
> the following program...

> #!perl

> use Win32::Clipboard;

> my $String = "Hello World\nHow are You?\n";
> print "$String";
> Win32::Clipboard::Set($String);

> Whe I run this script:
> The output generated on the screen...

> Hello World
> How are You?

> But the data that is present in the clipboard is "Hello WorldHow
> are You?" This I get in the Windows Notepad, but in the MS Word I
> get two lines.

> Would appreciate if anyone could point out how to add a DOS NewLine
> in the Clipboard - maybe we need to add one more char other than
> "\n"

Try "\r\n".

/ Gunnar

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



Mon, 21 Nov 2005 20:00:13 GMT  
 How to add multiple lines to the clipboard...
On Fri, 6 Jun 2003 02:38:52 +0800, "Shyamsunder Haldar "

Quote:

>Would appreciate if anyone could point out how to add a DOS NewLine in the
>Clipboard - maybe we need to add one more char other than "\n"

Try

$your_string = "line 1 \r\nline2\r\n";



Mon, 21 Nov 2005 20:14:57 GMT  
 How to add multiple lines to the clipboard...

Quote:

> Hi,

> How do I add text (multiple lines)to the Windows Clipboard..
> I have the following program...

> #!perl

> use Win32::Clipboard;

> my $String = "Hello World\nHow are You?\n";
> print "$String";
> Win32::Clipboard::Set($String);

> Whe I run this script:
> The output generated on the screen...

> Hello World
> How are You?

> But the data that is present in the clipboard is "Hello WorldHow are You?"
> This I get in the Windows Notepad, but in the MS Word I get two lines.

> Would appreciate if anyone could point out how to add a DOS NewLine in the
> Clipboard - maybe we need to add one more char other than "\n"

exactly. As perlport points out, "\n" i becomes a CRLF on windows when it's
leaving via some IO-Stream, which happens when you print to the terminal but not
when you set the windows clipboard.

So rather be explicit:

my $string = "Hello World\015\012How are You?\015\012";
print $string;
Win32::Clipboard::Set($string);

note: using "\r\n" is no quite right, as it will become CRCRLF when printed to
the terminal.

See perldoc perlport

--



'i`bjds') #my email-address is reversed!      <http://fruiture.de>



Mon, 21 Nov 2005 20:49:23 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. scriptlet to add line breaks at even multiples?

2. Is Windows Clipboard the same as Tk Clipboard?

3. line-by-line add to HTML-output

4. line-by-line add to HTML-output

5. Regex problem: Multiple matches across Multiple lines

6. Regex Multiple occurances of a pattern in multiple lines

7. s/// multiple lines in file from cmd line

8. Sorting multiple-line data to single line data

9. button to add multiple widgets to mainwindow???

10. Tk800.014 Patch - add xview/yview submethods (was Re: Help Multiple

11. adding passwords accross multiple serveers

12. Adding the contents of multiple files.

 

 
Powered by phpBB® Forum Software