-
1. Re: Pass string to clipboard (javascript)
Paul Riggott Mar 3, 2011 7:40 AM (in response to Ghoulfool)If you are using CS4 or CS5 this should work...
var string = "This is text for clipboard test"; system("echo "+ string +"|clip"); -
2. Re: Pass string to clipboard (javascript)
Ghoulfool Mar 3, 2011 7:46 AM (in response to Paul Riggott)Sadly no; using CS2
System is not a function
-
3. Re: Pass string to clipboard (javascript)
Michael L Hale Mar 4, 2011 7:27 AM (in response to Ghoulfool)In CS2 you should be able to write a temp bat file for your Exentdscript that does the same thing as Paul's system call and then run the bat file with file.execute() then remove the bat file.
It's more work than using system but can be done.
-
4. Re: Pass string to clipboard (javascript)
Ghoulfool Mar 4, 2011 7:51 AM (in response to Michael L Hale)Something like this? Only clipe.exe doesn't get shipped with XP
copyTextToClipboard(str)
function copyTextToClipboard(text)
{
var folderForTempFiles = Folder.temp.fsName;// 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("cat \"" + folderForTempFiles + "/ClipBoard.txt\"|clip");
clipBatFile.close();
clipBatFile.execute();
} -
5. Re: Pass string to clipboard (javascript)
Michael L Hale Mar 4, 2011 8:18 AM (in response to Ghoulfool)Ghoulfool wrote:
Something like this? Only clipe.exe doesn't get shipped with XP
Yes, you will have to get clip from another system that has it or a non Mircosoft replacement. You can find one doing a Google search.
And I was thinking more along the lines of the code below. It only needs one temp file.
var str = "text to clipboard"; copyTextToClipboard(str) function copyTextToClipboard(text){ var folderForTempFiles = Folder.temp.fsName; var clipBatFile =new File(folderForTempFiles + "/ClipBoard.bat"); clipBatFile.open('w'); clipBatFile.writeln("echo "+text+" | clip"); clipBatFile.close(); clipBatFile.execute(); clipBatFile.remove(); };


