Method clipboard.tryPaste
Overload
Calls clipboard.paste and handles exceptions.
public static bool tryPaste(string text, int timeout, bool warning = false, bool osd = false, string html = null, OKey options = null, KHotkey hotkey = default)
Parameters
text (string)
Text. Can be |
timeout (int)
Max time to wait until the focused app gets clipboard data, in milliseconds. The function waits up to 10 times longer if the window is hung. |
warning (bool)
Call print.warning. |
osd (bool)
Call osdText.showTransparentText with text |
html (string)
HTML. Can be full HTML or fragment. See clipboardData.AddHtml. Can be |
options (OKey)
Options. If |
hotkey (KHotkey)
Keys to use instead of |
Returns
bool
Returns |
Remarks
Sets clipboard data, sends keys Ctrl+V
, waits until the focused app gets clipboard data, finally restores clipboard data.
Fails if nothing gets clipboard data in several seconds.
Works with console windows too, even if they don't support Ctrl+V
.
A clipboard viewer/manager program can make this function slower and less reliable, unless it supports ClipFormats.ClipboardViewerIgnore or gets clipboard data with a delay. Possible problems with some virtual PC programs. Either pasting does not work in their windows, or they use a hidden clipboard viewer that makes this function slower and less reliable.