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

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

Participant ,
Jul 12, 2023 Jul 12, 2023

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
215
Translate
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

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();
Translate
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
LATEST

I see. Thank you very much for this reply!

Translate
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