Skip to main content
Participant
January 20, 2009
Question

Possible to copy string to Windows clipboard?

  • January 20, 2009
  • 1 reply
  • 555 views
I'm trying to write a short script to add a context menu item that copies the selected item's URI to the Windows clipboard so I can paste it into an email.

The following code shows the string in an alert box:

if (app.document.selections.length==1)
{
var myPath = decodeURI( app.document.selections[0].path);
alert(myPath);
} else if (app.document.selections.length==0 || app.document.selections.length>1)
{
alert("Please select single file or folder");
}

I thought this might be ok but since I can't highlight the text on the alert box it doesn't help much. Is there any way to copy a string from the script into the Windows clipboard?
This topic has been closed for replies.

1 reply

Participant
January 20, 2009
I've just come up with a temporary solution. Replacing the alert with a prompt box with the path as the default text means I can copy it.

Replace:
alert(myPath);

with:
prompt("",myPath);

It's not as quick as I'd like since I have to right-click the text, select copy then close the prompt box. But it's the best solution I've got so far.