Home > FAQ > Useful Basic Tasks when writing a script > How can I populate Clipboard in a script?

How can I populate Clipboard in a script?

You can select the desired text and simulate Control + c.

For example within notepad, Control + a is used to select all the text, then Control + c is used to copy the text to Clipboard:
UseWindow("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1)
SendKeys("Some text")
SendKeys("<Ctrl a>")
SendKeys("<Ctrl c>")

If the text to select and copy is big, add a line:
Pause 20 ticks
between the Control+c and GetClipboard$ action. A tick is around 1/100 second.

You can populate directly the Clipboard using SetClipboard function as in this example using notepad:
a$="Some text"
UseWindow("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1)
SendKeys("<Ctrl v>")

Control + v copies the clipboard content.