user interface – Copy selected browser text to clipboard python

i’m programming an application, which copies selected text from a browser to the clipboard (later to excel) by pressing a specific configurable hotkey.

I use tkinter and the following code. Problem is, the selected text won’t be copied to the clipboard.I just tested it out of the IDE.

from tkinter import *
import keyboard
import pyperclip
import pyautogui
import time


root = Tk()

def copy_clipboard():
    pyautogui.hotkey('ctrl', 'c')
    time.sleep(.01)
    copied_text = pyperclip.paste()
    insertin(copied_text)

def insertin(sString):
    eExcel.insert(10, sString)

canvas = Canvas(root, width=600, height=150)
#canvas.grid(columnspan=1)
Label(root, text="Clipboard-content").grid(row=0)
eCC = Entry(root)
eCC.grid(row=0, column=1)

keyboard.add_hotkey('alt + 1', lambda: copy_clipboard())


root.mainloop()

Has anyone a solution? Thanks in advance.