# Send text to clipboard - Perspective

**URL:** <https://forum.inductiveautomation.com/t/send-text-to-clipboard-perspective/37659>\
**Category:** Ignition\
**Created:** [August 12, 2020, 4:48pm UTC](https://forum.inductiveautomation.com/t/send-text-to-clipboard-perspective/37659 "2020-08-12T16:48:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![victor1](https://avatars.discourse-cdn.com/v4/letter/v/6de8d8/32.png) [@victor1](https://forum.inductiveautomation.com/u/victor1)\
**Post date:** [August 12, 2020, 4:48pm UTC](https://forum.inductiveautomation.com/t/send-text-to-clipboard-perspective/37659/1 "2020-08-12T16:48:37Z")

</div>

How can I send information to the clipboard from perspective?

I found this solution here on the forum:

```auto
from java.awt import Toolkit
from java.awt.datatransfer import StringSelection

def copy_clipboard(texto):
	clipboard = Toolkit.getDefaultToolkit().getSystemClipboard()
	clipboard.setContents(StringSelection(texto),None)

```

It works in the script console, but when I call this function on an onActionPerformed from a perspective button, it doesn’t work. This error happens:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/a/2a18728bdda25cfc239b10b2961e029e5a9ec51b.png)

Has anyone here tried this?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 12, 2020, 5:00pm UTC](https://forum.inductiveautomation.com/t/send-text-to-clipboard-perspective/37659/2 "2020-08-12T17:00:33Z")

</div>

Perspective scripts run in the gateway, not in the browser. You’ll need a custom component that can run real javascript, I suspect. Though I don’t know if browser security would let you do it anyways.

---

<div class="post-metadata">

**Author:** ![brandon1](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@brandon1](https://forum.inductiveautomation.com/u/brandon1)\
**Post date:** [August 12, 2020, 9:12pm UTC](https://forum.inductiveautomation.com/t/send-text-to-clipboard-perspective/37659/3 "2020-08-12T21:12:03Z")

</div>

Well I will say that there are web pages that provide buttons that will copy text into the clipboard so I would say it is possible but as @pturmel said you have to make a custom component to do that.

---

<div class="post-metadata">

**Author:** ![victor1](https://avatars.discourse-cdn.com/v4/letter/v/6de8d8/32.png) [@victor1](https://forum.inductiveautomation.com/u/victor1)\
**Post date:** [August 13, 2020, 11:13am UTC](https://forum.inductiveautomation.com/t/send-text-to-clipboard-perspective/37659/4 "2020-08-13T11:13:44Z")

</div>

Is there any documentation on creating a custom component?

---

<div class="post-metadata">

**Author:** ![brandon1](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@brandon1](https://forum.inductiveautomation.com/u/brandon1)\
**Post date:** [August 13, 2020, 11:46am UTC](https://forum.inductiveautomation.com/t/send-text-to-clipboard-perspective/37659/5 "2020-08-13T11:46:07Z")

</div>

> **[inductiveautomation/ignition-sdk-examples](https://github.com/inductiveautomation/ignition-sdk-examples/tree/master/perspective-component)**
>
> master/perspective-component

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [March 17, 2022, 1:05am UTC](https://forum.inductiveautomation.com/t/send-text-to-clipboard-perspective/37659/6 "2022-03-17T01:05:06Z")

</div>

Hey Victor, did you get anywhere with this in the end?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [March 17, 2022, 7:52am UTC](https://forum.inductiveautomation.com/t/send-text-to-clipboard-perspective/37659/7 "2022-03-17T07:52:27Z")

</div>

The java script side wouldnt be hard `navigator.clipboard.writeText("sometext")`

What are you trying to copy?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [March 17, 2022, 9:04am UTC](https://forum.inductiveautomation.com/t/send-text-to-clipboard-perspective/37659/8 "2022-03-17T09:04:34Z")

</div>

Me, I want to copy json for dev tools

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [March 17, 2022, 9:14am UTC](https://forum.inductiveautomation.com/t/send-text-to-clipboard-perspective/37659/9 "2022-03-17T09:14:58Z")

</div>

hmm you should be able to print objects to the console.log with system.util.print()

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/7/877d7189a4f4d7fd6e12ebd085785a494bbae82a.png)
