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

Copy text to clipboard while dialog is open (via script)

Participant ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

Hi,

 

I have a JavaSript script that shows a dialog.

While that dialog is still open, I want to copy some string to the clipboard.

I've tried adding a dummy text frame with that string as its content, selecting the content, and invoking app.copy(). But that doesn't work.

I think the reason it doesn't work is that the open dialog prevents adding a new text frame.

Do you have a solution?

 

Two possibly important details:

If I could access the clipboard directly, that would be fine. The reason behind the above-mentioned method is that it seems there's no direct access to the clipboard.

I need the script to tun on both macOS and Windows.

 

Thanks!

TOPICS
Scripting

Views

130

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 ,
Jul 13, 2023 Jul 13, 2023

Copy link to clipboard

Copied

You need a palette-style window for that. And the only way to then do it is what you described: a frame in which you select some text.

 

w = new Window('palette');
  w.copy = w.add ('button', undefined, 'Copy');
  w.copy.onClick = function () {
    app.copy();
	}
w.show();

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
Participant ,
Jul 13, 2023 Jul 13, 2023

Copy link to clipboard

Copied

LATEST

I see. Thank you very much for this reply!

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