Method clipboard.tryCopy
Overload
Calls clipboard.copy and handles exceptions.
public static bool tryCopy(out string text, int timeout, bool warning = false, bool osd = false, OKey options = null, KHotkey hotkey = default)
Parameters
text (string)
Receives the copied text. |
timeout (int)
Max time to wait until the focused app sets 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 |
options (OKey)
Options. If |
hotkey (KHotkey)
Keys to use instead of |
Returns
bool
Returns |
Remarks
Also can get file paths, as multiline text.
Sends keys Ctrl+C
, waits until the focused app sets clipboard data, gets it, finally restores clipboard data.
Fails if the focused app does not set clipboard text or file paths, for example if there is no selected text/files.
Works with console windows too, even if they don't support Ctrl+C
.