Copy highlighted text to clipboard, then use the clipboard to append it to a list

后端 未结 5 997
刺人心
刺人心 2020-12-16 18:54

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.

5条回答
  •  醉梦人生
    2020-12-16 19:07

    Well... Here it is:

    from tkinter import Tk
    
    def copy_clipboard():
        clipboard = Tk().clipboard_get()
        return clipboard
    

    Tk().clipboard_get() returns the current text in the clipboard.

    And you need to use pyautogui.hotkey('ctrl', 'c') first.

提交回复
热议问题