Method clipboard.copy
Overload
Gets the selected text from the focused app using the clipboard.
public static string copy(bool cut = false, OKey options = null, KHotkey hotkey = default, int timeoutMS = 0)
Parameters
cut (bool)
Use |
options (OKey)
Options. If |
hotkey (KHotkey)
Keys to use instead of |
timeoutMS (int)
Max time to wait until the focused app sets 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. |
Returns
Exceptions
AuException
Failed. Fails if there is no focused window or if it does not set clipboard data. |
InputDesktopException |
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
.