Copy to Clipboard

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
terrachild
Posts: 1
Joined: June 20th, 2013, 12:22 pm

I've been trying to get some help on pasting to the clipboard on a few boards, but no one has this solved yet.

I need a cross-platform way to copy from Extendscript to the system clipboard, any system clipboard.
puzzlingly, Extendscript doesn't allow this. Every language I've programmed in allows this. Strange.

I have two work-arounds:
1)
I can put the text on a textlayer and then copy it to the clipboard with: app.executeCommand(app.findMenuCommandId("Copy"));
But to do that the text has to be selected. Which can be done with: app.executeCommand(app.findMenuCommandId("Select All"));
However, the cursor must be in the field for that to work.
I'm trying to place the cursor in a textlayer text field with Extendscript in After Effects. I can't see anyway to do that.

2)
I can create an external file from Extendscript like this:

Code: Select all

//This works on Vista and Win 7,  XP requires the user to copy 'clip.exe' to the 'sys32' folder.
function copyTextToClipboard2(text)
{
   var folderForTempFiles = Folder.temp.fsName;
   //alert(folderForTempFiles)
   // create a new textfile and put the text into it
   var clipTxtFile =new File(folderForTempFiles + "/ClipBoard.txt"); 
   clipTxtFile.open('w'); 
   clipTxtFile.write(text); 
   clipTxtFile.close();

   // use the clip.exe to copy the contents of the textfile to the windows clipboard
   var clipBatFile =new File(folderForTempFiles + "/ClipBoard.bat"); 
   clipBatFile.open('w'); 
   clipBatFile.writeln("clip < " + folderForTempFiles + "/ClipBoard.txt"); 
   clipBatFile.close(); 
   clipBatFile.execute();
}
However, to make this work cross-platform, I need a mac version.
I could test for which OS people are on and then use the correct function.

Does anyone have an apple script version of the above function that could be executed from within Extendscript?
MarqueIV
Posts: 1
Joined: November 22nd, 2020, 6:06 pm

Ever figure this out? Also, do you know if this works for Illustrator too, or just After Effects?

User avatar
zlovatt
Posts: 47
Joined: October 31st, 2016, 5:00 pm
Location: Portland
Contact:

For what it's worth, aequery has a copyToClipboard() function-- https://aequery.aenhancers.com/aeq.comm ... oClipboard

Post Reply