I\'m trying to automate some actions in a browser or a word processor with pyautogui module for Python 3 (Windows 10).
There is a highlighted text in a browser.
What soundstripe posted is valid, but doesn't take into account copying null values when there was a previous value copied. I've included an additional line that clears the clipboard so null-valued copies remain null-valued:
import pyautogui as pya
import pyperclip # handy cross-platform clipboard text handler
import time
def copy_clipboard():
pyperclip.copy("") # <- This prevents last copy replacing current copy of null.
pya.hotkey('ctrl', 'c')
time.sleep(.01) # ctrl-c is usually very fast but your program may execute faster
return pyperclip.paste()
# double clicks on a position of the cursor
pya.doubleClick(pya.position())
list = []
var = copy_clipboard()
list.append(var)
print(list)