I am trying to copy data from a string variable in c# like below,
Clipboard.SetText(StringValue));
and then trying to paste it using,
SendKeys.Send("^{v}");
but this is not working it throws ThreadStateException exception and when i try to use STA Thread like below,
Thread thread = new Thread(() => Clipboard.SetText(Stringvalue));
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
SendKeys.Send("^{v}");
it gives me error at SendKeys.Send line about InvalidOperationException.
I have also tried Sendkeys.SendWait("^{v}"); but it does not work either.
NOTE:
Please note that my target application is WPF and I am writing code on another application to paste the value inside my target WPF application.