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

How can I use Clipboard content in a script?

You can retrieve the content of Clipboard and store it into a variable using GetClipboard$ function, and then use the variable as parameter for a function sending the retrieved text.

In this example, the Clipboard content is typed to a notepad window:
a$=GetClipboard$()
UseWindow("NOTEPAD.EXE|Edit|")
SendKeys(a$)
 

In this second example, the Clipboard content is used to fill a field in a Web form:
a$=GetClipboard$()
UsePage("WinTask")
WriteHTML("INPUT TEXT[NAME= 'company']", a$)

To remove undesirable characters such as Space or Tab, use Trim$ function:
a$=GetClipboard$()
UsePage("WinTask")
WriteHTML("INPUT TEXT[NAME= 'company']", Trim$(a$))