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

Is it possible to load the clipboard with text from a script

Engaged ,
Oct 17, 2022 Oct 17, 2022

Copy link to clipboard

Copied

I have a script that exports images at different sizes and depending on the name it will write to text document a path to that image. So Example.jpg is located in Server-1/A-F or Server-1/G-K etc. What I would like to do is instead of writing that to a text file, would be to load it to the clipboad so I could paste it in an email, is this possible? 

TOPICS
Scripting

Views

257

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
People's Champ ,
Oct 17, 2022 Oct 17, 2022

Copy link to clipboard

Copied

Use the search function : this has been already discussed many times :

https://community.adobe.com/t5/indesign-discussions/script-to-copy-clipboard-contents-into-object-ex...

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
Advisor ,
Oct 17, 2022 Oct 17, 2022

Copy link to clipboard

Copied

@davidn5918184,

It would be helpful if you posted the code for the script you're using...

 

"I have a script that exports images at different sizes and depending on the name it will write to text document a path to that image".

 

It seems like it would be an easy change from writing to a text file to getting that info copied to the clipboard.

 

Regards,

Mike

 

 

 

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 ,
Oct 17, 2022 Oct 17, 2022

Copy link to clipboard

Copied

Hi @davidn5918184 , I use these 2 functions for getting and setting the clipboard. So assuming you have an image direct selected, this copies its file path to the clipboard:

 

/**
* Sets the clipboard to the provided string
* @ return void
*/
function setClipboard(s){
    var tf = app.activeDocument.pages[0].textFrames.add()
	tf.parentStory.texts[0].select();
    tf.parentStory.contents = s;
    tf.parentStory.texts.everyItem().select(SelectionOptions.REPLACE_WITH)
	app.copy()
    tf.remove()
}

/**
* Gets the clipboard text contents
* @ return the clipboard‘s text as a string 
*/
function getClipboard(){
    var tf = app.activeDocument.pages[0].textFrames.add()
	tf.parentStory.texts[0].select()
	app.paste()
	var cb = tf.parentStory.contents.toString();
    tf.remove()
    return cb
}

 

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
Engaged ,
Oct 17, 2022 Oct 17, 2022

Copy link to clipboard

Copied

Thank you. The difference is I want to load the clipboard with a string, but this is interesting, app.copy().  Could you put a varible in there?

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
Advisor ,
Oct 17, 2022 Oct 17, 2022

Copy link to clipboard

Copied

@davidn5918184,

 

Yes, you could probably use app.copy() to change from writing to a text file to getting that info copied to the clipboard.

If you have a single image selected you could try this..

 

//Copy Full Path
app.menuActions.itemByID(132623).invoke();

 

Regards,

Mike

 

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 ,
Oct 17, 2022 Oct 17, 2022

Copy link to clipboard

Copied

LATEST

Could you put a varible in there?

 

Sorry I forgot to include the call. With an image selected run this—imgPath is the image’s file path as a string:

 

 

var imgPath = app.selection[0].itemLink.filePath;
setClipboard(imgPath)



/**
* Sets the clipboard to the provided string
* @ return void
*/
function setClipboard(s){
    var tf = app.activeDocument.pages[0].textFrames.add()
	tf.parentStory.texts[0].select();
    tf.parentStory.contents = s;
    tf.parentStory.texts.everyItem().select(SelectionOptions.REPLACE_WITH)
	app.copy()
    tf.remove()
}

 

 

Screen Shot 11.png

 

 

My clipboard in Mail pastes this:

 

ARCHIVE 8T:PHOTOGRAPHY & ART:PHOTOGRAPHY:EBAY:Woody Jackson:Rubin'sCow01

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