Copy text to clipboard

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
benroll

Hi all,

I'm new here. Been struggling along with the Adobe Scripting Guide and the time-honored trial and error method for a long while now, so I thought I'd finally bite the bullet and sign up here!

Anyway, my problem is at the moment that I'm trying to think of a way to copy a text string that is generated within a script to the clipboard so that the user can paste it later.

Is there a way to do this?

Thanks if you can help.

-Ben.
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

Hey Ben

On mac you can use pbcopy http://ss64.com/osx/pbcopy.html
Not sure about windows, have never looked into it but there must bea way.

Lloyd
benroll

Thanks Lloyd. I'll check it out.

-B.
benroll

Works in terminal...

Code: Select all

echo text to copy | pbcopy
but how do I call that from the jsx file? I can find plenty of info on calling javascripts from Apple script, but nothing for the other way round.

-Ben.
benroll

This is my copy_to_clipboard.jsx so far.

Code: Select all

alert(system.osName);
alert(system.callSystem('osascript -e \'   echo hello | pbcopy   \''));
//alert(system.callSystem('arch -i386 osascript -e \'   echo hello | pbcopy   \''));
alert("done");
But the second line is returning a syntax error. I get the same in Applescript editor. I guess what I'm asking is whether anyone knows of a good web page for Applescript noobs! :D

-Ben.
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

No need for applescript.

Code: Select all

var myTextString = "I am going on a ride on the clipboard";
system.callSystem("echo " +  myTextString + " | pbcopy");
-Lloyd
benroll

Aha! Thanks for that Lloyd... Actually, I just cracked it using the verbose Applescript syntax too, but your method is much better.

Code: Select all

alert(system.callSystem('osascript -e \'   tell application "Finder" to set the clipboard to "I have copied"   \''));
Now to move on to the PC version. Oh dear. I don't even have a PC. :)

-Ben.
Post Reply