# How to create .NET “System.Windows.Clipboard”?

I have followed the instructions for creating a blank .Net form and it works.

Needs["NETLink"]
InstallNET[];
myform = NETNew["System.Windows.Forms.Form"];
ShowNETWindow[myform];
(* Don't forget to release it later *)
ReleaseNETObject[myform];


However, I cannot get a reference to "System.Windows.Clipboard".

clipboard = NETNew["System.Windows.Clipboard"]


What am I missing?

First, we must load the PresentationCore assembly to make the type System.Windows.Clipboard available:

Needs["NETLink"]
InstallNET[];



Second, System.Windows.Clipboard is a static class so it cannot be instantiated using NETNew. We must import its static members instead:

LoadNETType["System.Windows.Clipboard", AllowShortContext -> False];


Now, we can access the clipboard through static members such as GetText:

CopyToClipboard["hi there"]

SystemWindowsClipboardGetText[]
(* "hi there" *)
`
• Very nice. (+1) Holding out for more just in case. – Edmund Mar 3 '17 at 19:40