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.
Copy text to clipboard
Moderator: Paul Tuersley
- 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
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
Works in terminal...
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.
Code: Select all
echo text to copy | pbcopy
-Ben.
This is my copy_to_clipboard.jsx so far.
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! 
-Ben.
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");

-Ben.
- lloydalvarez
- Enhancement master
- Posts: 460
- Joined: June 17th, 2004, 9:27 am
- Location: New York City, NY
- Contact:
No need for applescript.
-Lloyd
Code: Select all
var myTextString = "I am going on a ride on the clipboard";
system.callSystem("echo " + myTextString + " | pbcopy");
Aha! Thanks for that Lloyd... Actually, I just cracked it using the verbose Applescript syntax too, but your method is much better.
Now to move on to the PC version. Oh dear. I don't even have a PC. 
-Ben.
Code: Select all
alert(system.callSystem('osascript -e \' tell application "Finder" to set the clipboard to "I have copied" \''));

-Ben.