public void SetClipboardText(string Text) { int timeout = 5; while (timeout-- > 0) { IntPtr cbTry = GetOpenClipboardWindow(); if (cbTry == IntPtr.Zero) break; System.Threading.Thread.Sleep(100); } try { Clipboard.SetText(Text); } catch (Exception ex) { this.Debug("Clipboard.SetText threw " + ex.GetType().FullName + ": '" + ex.Message + "'"); } }