How do I write a program with Python that can act as a copy and paste in Windows? I made two buttons with the python library and want to do one copy in the windows environment and the other one in the paste. Thanks for helping me.
its my code
import tkinter as tk
import pyautogui as pg
import time
root = tk.Tk()
root.geometry("200x160")
root.resizable(False, False)
is_checked = tk.IntVar()
def alont():
if is_checked.get() == 0:
root.attributes('-topmost', False)
else:
root.attributes('-topmost', True)
text1 = tk.Entry(root, font = ("area", 10), width = 5)
text1.config(insertwidth=1)
text1.place(x=10, y=137)
text1.insert(0, 1)
timer1 = text1.get()
def copy1():
timer1 = text1.get()
tm = int(timer1)
time.sleep(tm)
pg.hotkey('ctrl', 'c')
def paste1():
timer1 = text1.get()
tm = int(timer1)
time.sleep(tm)
pg.hotkey('ctrl', 'v')
btn1 = tk.Button(root, text="Copy", font=("area", 25), height = 1, width = 10)
btn1.config(command=copy1)
btn1.pack()
btn2 = tk.Button(root, text="Paste", font=("area", 25), height = 1, width = 10)
btn2.config(command=paste1)
btn2.pack()
chbutton = tk.Checkbutton(root, text="Always On Top",
font=("area", 12), variable=is_checked)
chbutton.config(command=alont)
chbutton.place(x=60, y=133.5)
root.mainloop()