Skip to main content
orib7317974
Known Participant
July 12, 2023
Question

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

  • July 12, 2023
  • 1 reply
  • 312 views

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!

This topic has been closed for replies.

1 reply

Braniac
July 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();
orib7317974
Known Participant
July 13, 2023

I see. Thank you very much for this reply!