Method clipboard.paste
Overload
Pastes text or HTML into the focused app using the clipboard.
public static void paste(string text, string html = null, OKey options = null, KHotkey hotkey = default, int timeoutMS = 0)
Parameters
text (string)
Text. Can be |
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 |
timeoutMS (int)
Max time to wait until the focused app gets clipboard data, in milliseconds. If 0 (default), the timeout is 3000 ms. The function waits up to 10 times longer if the window is hung. |
Exceptions
AuException
Failed. Fails if there is no focused window or if it does not get clipboard data. |
InputDesktopException |
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.
Examples
clipboard.paste("Example\r\n");