Method clipboard.pasteData
Overload
Pastes data added to a clipboardData variable into the focused app using the clipboard.
public static void pasteData(clipboardData data, OKey options = null, KHotkey hotkey = default, int timeoutMS = 0)
Parameters
data (clipboardData) |
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
Paste data of two formats: HTML and text.
clipboard.pasteData(new clipboardData().AddHtml("<b>text</b>").AddText("text"));