Clipboard & Useful Things

Hi all,

I’m trying to access the clipboard in the Sanderling Bot window but to do so I need to include the line…
using System.Windows.Forms;

However the bot windows says System.Windows doesn’t have a Forms namespace.

Any advice?

Thanks.

Sorry - Should have searched better.
#r “System.Windows.Forms” at the top of the window.

If I remember correctly you will have problems with using the clipboard due to threading.

I believe I found a workaround/fix by creating a new thread , setting the ApartmentState to STA
here is a snippet I use

using System.Threading;
public static void SetText(string textToSet) => Clipboard.SetText(textToSet);

Thread thread = new Thread( () => SetText(string stringtoSet));
thread.SetApartmentState(ApartmentState.STA);
thread.Start();

I have successfully used this to set the results from the ProbeScanner into the Clipboard and manipulated them outside of the Sanderling Environment.

Maniac

Thanks for the code.
I did find out that “for some reason” I couldn’t read the ClipBoard so I used a file instead. I’ll give your solution a go.

Cheers.