• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

copy text to the clipboard or retrieve text from the clipboard.

Explorer ,
Sep 06, 2016 Sep 06, 2016

Copy link to clipboard

Copied

Hello everyone. I would ask if it is possible to copy a text to the clipboard content from a javascript illustrator.

I also like to do the operation in reverse. retrieve text from the clipboard as a variable to use.

I have read on the Internet could be done by Bat or AppleScript files but I have been tested and have not gotten it to work.

It could run both Windows and Mac? It is possible?

I would appreciate any help. Keep looking information

Many thanks

a greeting

TOPICS
Scripting

Views

657

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Explorer ,
Sep 11, 2016 Sep 11, 2016

Copy link to clipboard

Copied

Hello such.

I've been looking information and have found a method that should work, but I'm not able to do.

The process would create a txt file and a file ejectutable (MAC) (command ?? sh?) And using this file created dynamically txt copy the contents to clipboard

Could anyone help me, please?

I am a novice in these matters, and even more in what refers to MAC

I guess it would be like a windows bat file, but I searched information but I do not know how to dynamically create and run it on Mac

I would appreciate any help.

Thank you very much.

A greeting. Excuse my English

var doc = app.activeDocument;

var text = doc.textFrames[0].contents;

//alert(text)

copyTextToClipboard2(text)

function copyTextToClipboard2(text){

    var folderForTempFiles = '~/Desktop';

    var clipTxtFile = new File(folderForTempFiles + "/ClipBoardMac.txt");

    clipTxtFile.open('w');

    clipTxtFile.encoding = "UTF-8";

    clipTxtFile.lineFeed = "Unix";

    clipTxtFile.write(text);

    clipTxtFile.close();

    var clipBatFile = new File(folderForTempFiles + "/ClipBoard.command");

    if (clipBatFile.exists) {

        clipBatFile.remove();

    }

    clipBatFile.open('w');

    //clipBatFile.writeln("cat \"" + folderForTempFiles + "/ClipBoard.txt\"|clip");

    //clipBatFile.write("cat " + folderForTempFiles + " | pbcopy");

    clipBatFile.writeln("#!/bin/bash"+"\n"+"cat " + folderForTempFiles + "/ClipBoardMac.txt" + " | pbcopy");

    clipBatFile.close();

    clipBatFile.execute();

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 11, 2016 Sep 11, 2016

Copy link to clipboard

Copied

Why don't you use copy and paste methods like below?

function copytxt(){

  if (app.selection.length==1&&app.selection[0].typename=="TextFrame")

  app.copy();

  }

function getclipboardtxt(){

  app.paste();

  var tx = app.activeDocument.textFrames[0].contents;

  app.activeDocument.textFrames[0].remove();

  return tx;

  }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 12, 2016 Sep 12, 2016

Copy link to clipboard

Copied

LATEST

thanks for your answer but my intent is to copy the unformatted text

a greeting

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines