How do I put a text file contents in the clipboard?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Nilson Neves

How do I put a text file contents in the clipboard?

Post by Nilson Neves » Tue Feb 03, 2004 6:27 pm

Writing the clipboard to a file is easy:

GetClipBoard>WhatsInTheClipBoard1
WriteLn>C:\file.txt,result,WhatsInTheClipBoard2

How I put the file contents in the clipboard so that the arrangement (newline chars) is not changed?

Nilson Neves

Windows with TWO clipboards. Test it.

Post by Nilson Neves » Tue Feb 03, 2004 9:26 pm

One way to put text from a file in clipboard is given in the script Clipboard2 Paste.scp.



Clipboard2 COPY.scp

GetClipBoard>WhatsInTheClipBoard1
rem Message>WhatsInTheClipBoard1
Press CTRL
Send Character/Text>c
Release CTRL
GetClipBoard>WhatsInTheClipBoard2
rem Message>WhatsInTheClipBoard2
Let>file=TEMP_DIR
ConCat>file,clipboard2.txt
PutClipBoard>WhatsInTheClipBoard1
DeleteFile>file
WriteLn>file,result,WhatsInTheClipBoard2




Clipboard2 Paste.scp

Let>file=TEMP_DIR
ConCat>file,clipboard2.txt
ReadLn>file,1,entiretext
Let>k=2
Label>start
ReadLn>file,k,line
If>line=##EOF##,finish
Let>entiretext=%entiretext%%CR%%line%
Let>k=k+1
Goto>start
Label>finish
GetClipBoard>WhatsInTheClipBoard1
PutClipBoard>entiretext
Press CTRL
send>v
Release CTRL
PutClipBoard>WhatsInTheClipBoard1




sometimes in my Win98se the copy (CTRL-ALT-C) shows "cannot open clipboard"
...and the paste text (CTRL-ALT-V) sometimes is different.

comments, improvements?

Nilson Neves

Post by Nilson Neves » Tue Feb 03, 2004 11:37 pm

Please,
Replace %CR% by %CRLF%

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts