Workload Template - Get-Set Clipboard Text


This script contains a custom function that's able to retrieve and set clipboard text using P/Invoke.


GetClipboard - retrieves the current clipboard text

Example: create a new string variable containing the text output of the GetClipboard function.

var cbtext = GetClipboard();


SetClipboard - set a text/string to the clipboard


SetClipboard(string text);

Example: set clipboard text to "test 123" or perhaps a text output from a control such as an editbox.

SetClipboard("test 123");

SetClipboard(MainWindow.FindControl(className : "Document:Edit", title : "Text Editor").GetText());